lj
Lennard-Jones force terms for reduced-unit simulations.
import mlx_atomistic.lj
Classes
Section titled “Classes”LennardJonesPotential
Section titled “LennardJonesPotential”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
| Name | Type | Default | Description |
|---|---|---|---|
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 |
Methods
energy_forces
Section titled “energy_forces”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
| Name | Type | Default | Description |
|---|---|---|---|
positions | mx.array | Particle coordinates, shape (n_particles, 3). | |
cell | Cell | None | None | Optional periodic cell for minimum-image distances. Defaults to None. |
pairs | object | None | None | Optional 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— Ifpositionsis not(n_particles, 3)or a lazy topology is used without a runtime pair provider.