Skip to content

lj

Lennard-Jones force terms for reduced-unit simulations.

import mlx_atomistic.lj

class LennardJonesPotential
def __init__(epsilon: float = 1.0, sigma: float = 1.0, cutoff: float | None = 2.5, shift: bool = True, topology: Topology | None = None, one_four_scale: float = 1.0, backend: NonbondedBackend = 'auto', tile_size: int = 512, memory_budget_bytes: int | None = DEFAULT_DENSE_MEMORY_BUDGET_BYTES, name: str = 'lj', supports_virial: bool = True, analytic_virial_supported: bool = False, use_fused_kernel: bool = False)

Naive all-pairs Lennard-Jones potential in reduced units.

Parameters

NameTypeDefaultDescription
epsilonfloat1.0
sigmafloat1.0
cutofffloat | None2.5
shiftboolTrue
topologyTopology | NoneNone
one_four_scalefloat1.0
backendNonbondedBackend'auto'
tile_sizeint512
memory_budget_bytesint | NoneDEFAULT_DENSE_MEMORY_BUDGET_BYTES
namestr'lj'
supports_virialboolTrue
analytic_virial_supportedboolFalse
use_fused_kernelboolFalse

Methods

def energy_forces(positions: mx.array, cell: Cell | None = None, pairs: object | None = None) -> tuple[mx.array, mx.array]

Return potential energy and forces for positions with shape (n_particles, 3).

Parameters

NameTypeDefaultDescription
positionsmx.arrayParticle coordinates, shape (n_particles, 3).
cellCell | NoneNoneOptional periodic cell for minimum-image distances. Defaults to None.
pairsobject | NoneNoneOptional neighbor list, neighbor blocks, or dense pair array; the nonbonded backend is chosen automatically. Defaults to None.

Returns

  • tuple[mx.array, mx.array] — An (energy, forces) tuple: scalar LJ energy and forces of shape (n_particles, 3).

Raises

  • ValueError — If positions is not (n_particles, 3) or a lazy topology is used without a runtime pair provider.