Skip to content

charmm_terms

CHARMM-specific molecular mechanics force-term primitives.

import mlx_atomistic.charmm_terms

class CHARMMCMAPPotential
def __init__(charmm_cmap_terms: object, cmap_grids: object, cmap_indices: object | None = None, name: str = 'charmm_cmap_terms', supports_virial: bool = True)

CHARMM CMAP two-dihedral correction term with periodic bicubic interpolation.

Parameters

NameTypeDefaultDescription
charmm_cmap_termsobject
cmap_gridsobject
cmap_indicesobject | NoneNone
namestr'charmm_cmap_terms'
supports_virialboolTrue

Methods

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

Return the CMAP energy and per-atom forces (forces via autodiff).

Parameters

NameTypeDefaultDescription
positionsmx.arrayAtomic coordinates, shape (n_atoms, 3).
cellCell | NoneNoneOptional periodic cell; when given, distances use the minimum-image convention. Defaults to None.
pairsmx.array | NoneNoneAccepted for interface uniformity and ignored; the term uses its stored index list. Defaults to None.

Returns

  • tuple[mx.array, mx.array] — An (energy, forces) tuple: scalar energy and per-atom forces of shape (n_atoms, 3).
def potential_energy(positions: mx.array, cell: Cell | None = None) -> mx.array

Return the CHARMM CMAP two-dihedral correction energy.

Parameters

NameTypeDefaultDescription
positionsmx.arrayAtomic coordinates, shape (n_atoms, 3).
cellCell | NoneNoneOptional periodic cell; when given, distances use the minimum-image convention. Defaults to None.

Returns

  • mx.array — Total CMAP energy as a scalar array.
class CHARMMForceSwitchNonbondedPotential
def __init__(sigma: object, epsilon: object, charges: object, cutoff: float, switch_distance: float, coulomb_constant: float = 1.0, lj_shift: bool = False, coulomb_shift: bool = False, topology: object | None = None, lj_one_four_scale: float = 1.0, coulomb_one_four_scale: float = 1.0, exception_pairs: object = (), exception_charge_products: object | None = None, exception_sigma: object | None = None, exception_epsilon: object | None = None, backend: str = 'auto', tile_size: int = 512, memory_budget_bytes: int | None = None, name: str = 'charmm_force_switch_nonbonded', supports_virial: bool = True)

CHARMM LJ force-switch nonbonded primitive.

Parameters

NameTypeDefaultDescription
sigmaobject
epsilonobject
chargesobject
cutofffloat
switch_distancefloat
coulomb_constantfloat1.0
lj_shiftboolFalse
coulomb_shiftboolFalse
topologyobject | NoneNone
lj_one_four_scalefloat1.0
coulomb_one_four_scalefloat1.0
exception_pairsobject()
exception_charge_productsobject | NoneNone
exception_sigmaobject | NoneNone
exception_epsilonobject | NoneNone
backendstr'auto'
tile_sizeint512
memory_budget_bytesint | NoneNone
namestr'charmm_force_switch_nonbonded'
supports_virialboolTrue

Methods

def component_energies(positions: mx.array, cell: Cell | None = None, pairs: mx.array | None = None) -> dict[str, mx.array]

Return separate LJ and Coulomb force-switched energy components.

Parameters

NameTypeDefaultDescription
positionsmx.arrayAtomic coordinates, shape (n_atoms, 3).
cellCell | NoneNoneOptional periodic cell; when given, distances use the minimum-image convention. Defaults to None.
pairsmx.array | NoneNoneOptional explicit atom-pair list, shape (n_pairs, 2); None evaluates all unique pairs. Defaults to None.

Returns

  • dict[str, mx.array] — A dict of named energy components (e.g. "lj", "coulomb").
def energy_forces(positions: mx.array, cell: Cell | None = None, pairs: mx.array | None = None) -> tuple[mx.array, mx.array]

Return the force-switched LJ and Coulomb energy and per-atom forces.

Parameters

NameTypeDefaultDescription
positionsmx.arrayAtomic coordinates, shape (n_atoms, 3).
cellCell | NoneNoneOptional periodic cell; when given, distances use the minimum-image convention. Defaults to None.
pairsmx.array | NoneNoneOptional explicit atom-pair list, shape (n_pairs, 2); None evaluates all unique pairs. Defaults to None.

Returns

  • tuple[mx.array, mx.array] — An (energy, forces) tuple: scalar energy and per-atom forces of shape (n_atoms, 3).
def energy_forces_with_components(positions: mx.array, cell: Cell | None = None, pairs: mx.array | None = None) -> tuple[mx.array, mx.array, dict[str, mx.array]]

Return energy, forces, and LJ/Coulomb components in one pass.

Parameters

NameTypeDefaultDescription
positionsmx.arrayAtomic coordinates, shape (n_atoms, 3).
cellCell | NoneNoneOptional periodic cell; when given, distances use the minimum-image convention. Defaults to None.
pairsmx.array | NoneNoneOptional explicit atom-pair list, shape (n_pairs, 2); None evaluates all unique pairs. Defaults to None.

Returns

  • tuple[mx.array, mx.array, dict[str, mx.array]] — An (energy, forces, components) tuple.
def potential_energy(positions: mx.array, cell: Cell | None = None, pairs: mx.array | None = None) -> mx.array

Return the force-switched LJ and Coulomb energy.

Parameters

NameTypeDefaultDescription
positionsmx.arrayAtomic coordinates, shape (n_atoms, 3).
cellCell | NoneNoneOptional periodic cell; when given, distances use the minimum-image convention. Defaults to None.
pairsmx.array | NoneNoneOptional explicit atom-pair list, shape (n_pairs, 2); None evaluates all unique pairs. Defaults to None.

Returns

  • mx.array — Total force-switched nonbonded energy as a scalar array.
class CHARMMNBFIXPairOverridePotential
def __init__(sigma: object, epsilon: object, charges: object, nbfix_pairs: object, nbfix_sigma: object, nbfix_epsilon: object, coulomb_constant: float = 1.0, cutoff: float | None = 2.5, switch_distance: float | None = None, lj_shift: bool = False, coulomb_shift: bool = False, backend: str = 'auto', name: str = 'nbfix_pair_overrides', supports_virial: bool = True)

CHARMM NBFIX-style explicit-pair LJ override layered over regular nonbonded terms.

Parameters

NameTypeDefaultDescription
sigmaobject
epsilonobject
chargesobject
nbfix_pairsobject
nbfix_sigmaobject
nbfix_epsilonobject
coulomb_constantfloat1.0
cutofffloat | None2.5
switch_distancefloat | NoneNone
lj_shiftboolFalse
coulomb_shiftboolFalse
backendstr'auto'
namestr'nbfix_pair_overrides'
supports_virialboolTrue

Methods

def component_energies(positions: mx.array, cell: Cell | None = None, pairs: mx.array | None = None) -> dict[str, mx.array]

Return nonbonded components with the NBFIX LJ correction folded into the LJ term.

Parameters

NameTypeDefaultDescription
positionsmx.arrayAtomic coordinates, shape (n_atoms, 3).
cellCell | NoneNoneOptional periodic cell; when given, distances use the minimum-image convention. Defaults to None.
pairsmx.array | NoneNoneMust be None — NBFIX overrides require full-system evaluation. Defaults to None.

Returns

  • dict[str, mx.array] — A dict of named energy components (e.g. "lj", "coulomb").

Raises

  • ValueError — If pairs is not None.
def energy_forces(positions: mx.array, cell: Cell | None = None, pairs: mx.array | None = None) -> tuple[mx.array, mx.array]

Return the NBFIX-corrected nonbonded energy and per-atom forces.

Parameters

NameTypeDefaultDescription
positionsmx.arrayAtomic coordinates, shape (n_atoms, 3).
cellCell | NoneNoneOptional periodic cell; when given, distances use the minimum-image convention. Defaults to None.
pairsmx.array | NoneNoneMust be None — NBFIX overrides require full-system evaluation. Defaults to None.

Returns

  • tuple[mx.array, mx.array] — An (energy, forces) tuple: scalar energy and per-atom forces of shape (n_atoms, 3).

Raises

  • ValueError — If pairs is not None.
def potential_energy(positions: mx.array, cell: Cell | None = None) -> mx.array

Return the base nonbonded energy plus the NBFIX explicit-pair LJ correction.

Parameters

NameTypeDefaultDescription
positionsmx.arrayAtomic coordinates, shape (n_atoms, 3).
cellCell | NoneNoneOptional periodic cell; when given, distances use the minimum-image convention. Defaults to None.

Returns

  • mx.array — Total NBFIX-corrected nonbonded energy as a scalar array.
class CHARMMUreyBradleyPotential
def __init__(urey_bradley_terms: object, k: object, distance: object, name: str = 'urey_bradley', supports_virial: bool = True)

CHARMM Urey-Bradley 1-3 distance term for angle triplets.

Parameters

NameTypeDefaultDescription
urey_bradley_termsobject
kobject
distanceobject
namestr'urey_bradley'
supports_virialboolTrue

Methods

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

Return the Urey-Bradley energy and per-atom forces.

Parameters

NameTypeDefaultDescription
positionsmx.arrayAtomic coordinates, shape (n_atoms, 3).
cellCell | NoneNoneOptional periodic cell; when given, distances use the minimum-image convention. Defaults to None.
pairsmx.array | NoneNoneAccepted for interface uniformity and ignored; the term uses its stored index list. Defaults to None.

Returns

  • tuple[mx.array, mx.array] — An (energy, forces) tuple: scalar energy and per-atom forces of shape (n_atoms, 3).
def potential_energy(positions: mx.array, cell: Cell | None = None) -> mx.array

Return the CHARMM Urey-Bradley 1-3 energy 0.5 * sum(k * (r13 - r0)**2).

Parameters

NameTypeDefaultDescription
positionsmx.arrayAtomic coordinates, shape (n_atoms, 3).
cellCell | NoneNoneOptional periodic cell; when given, distances use the minimum-image convention. Defaults to None.

Returns

  • mx.array — Total Urey-Bradley energy as a scalar array.