Hamiltonian

class jaxrens.backends.hamiltonian.Hamiltonian(model, terms=())[source]

Bases: object

Energy model plus additive terms; satisfies the EnergyBackend protocol.

Parameters:
  • model (EnergyBackend) – The bare energy backend. If a Hamiltonian is passed, it is flattened: its model is used and its terms are prepended to terms, so composition never nests.

  • terms (Sequence[EnergyTerm]) – Additive EnergyTerm instances, summed in order after the model energy.

with_terms(*terms)[source]

Return a new Hamiltonian with terms appended.

Parameters:

terms (EnergyTerm)

Return type:

Hamiltonian

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

Per-layer energies and forces, summed.

The model goes through eval_energy_and_forces() (native force path when available, autodiff of the model alone otherwise); each term contributes its own EnergyTerm.energy_and_forces().

Parameters:
  • positions (Array)

  • species (Array)

  • cell (Array)

  • max_neighbors (int)

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

Return type:

BackendResult