Skip to content

dft.periodic_electrostatics

Periodic point-charge electrostatics for full-rank cells.

import mlx_atomistic.dft.periodic_electrostatics

def periodic_ewald_energy(charges: Sequence[float], positions: Sequence[Sequence[float]], cell_lengths: Cell | Sequence[float] | Sequence[Sequence[float]], *, eta: float | None = None, tolerance: float = 1e-10) -> float

Return periodic point-charge Ewald energy with neutralizing background.

Parameters

NameTypeDefaultDescription
chargesSequence[float]Point charges in atomic units.
positionsSequence[Sequence[float]]Cartesian positions in bohr.
cell_lengthsCell | Sequence[float] | Sequence[Sequence[float]]A periodic Cell, three orthorhombic lengths, or a full row-vector cell matrix in bohr.
etafloat | NoneNoneOptional Ewald splitting parameter in inverse bohr. Defaults to a cell-scaled value.
tolerancefloat1e-10Real/reciprocal truncation target. Defaults to 1e-10.

Returns

  • float — Ewald energy in Hartree.
def periodic_ewald_forces(charges: Sequence[float], positions: Sequence[Sequence[float]], cell_lengths: Cell | Sequence[float] | Sequence[Sequence[float]], *, displacement: float = 0.0001, eta: float | None = None, tolerance: float = 1e-10, method: str = 'analytic') -> np.ndarray

Return forces for the periodic Ewald ion-ion energy.

Parameters

NameTypeDefaultDescription
chargesSequence[float]Point charges in atomic units.
positionsSequence[Sequence[float]]Cartesian positions in bohr.
cell_lengthsCell | Sequence[float] | Sequence[Sequence[float]]A periodic Cell, three orthorhombic lengths, or a full row-vector cell matrix in bohr.
displacementfloat0.0001Central-difference step used only when method="finite_difference". Defaults to 1e-4.
etafloat | NoneNoneOptional Ewald splitting parameter. Defaults to a cell-scaled value.
tolerancefloat1e-10Ewald truncation target. Defaults to 1e-10.
methodstr'analytic'"analytic" or the validation-only "finite_difference". Defaults to "analytic".

Returns

  • np.ndarray — Force array with shape (n_ions, 3) in Hartree/bohr.
def periodic_ewald_stress(charges: Sequence[float], positions: Sequence[Sequence[float]], cell_lengths: Cell | Sequence[float] | Sequence[Sequence[float]], *, eta: float | None = None, tolerance: float = 1e-10) -> np.ndarray

Return compression-positive periodic Ewald stress.

Parameters

NameTypeDefaultDescription
chargesSequence[float]Point charges in atomic units.
positionsSequence[Sequence[float]]Cartesian positions in bohr.
cell_lengthsCell | Sequence[float] | Sequence[Sequence[float]]Periodic cell in bohr.
etafloat | NoneNoneOptional Ewald splitting parameter in inverse bohr.
tolerancefloat1e-10Real/reciprocal truncation target.

Returns

  • np.ndarray — Symmetric stress tensor in Hartree/bohr cubed.