Skip to content

dft.gga

PBE GGA exchange-correlation with an autodiff-derived potential.

The defining idea: a GGA energy is E_xc = ∫ ε(ρ, ∇ρ) dr, and its potential is the functional derivative v_xc = δE_xc/δρ = ∂ε/∂ρ - ∇·(∂ε/∂∇ρ). The gradient term is the part that is famously error-prone to hand-derive. Here we write only the energy density and obtain v_xc from mx.grad of the total energy — the autodiff machinery reconstructs the divergence term automatically, provided the density gradient is built with a differentiable (MLX-native) FFT.

import mlx_atomistic.dft.gga

class PBEExchangeCorrelation
def __init__(name: str = 'pbe-gga')

PBE GGA exchange-correlation; v_xc is the autodiff functional derivative.

The uniform-gas correlation baseline reuses the PZ81 parameterization already in the package (true PBE uses PW92; the difference is sub-mHa and the baseline is swappable).

Parameters

NameTypeDefaultDescription
namestr'pbe-gga'

Methods

def evaluate(density: mx.array, grid: RealSpaceGrid | None = None, *, density_floor: float = 1e-12) -> XCResult

Evaluate the PBE GGA exchange-correlation energy density, potential, and total energy.

Parameters

NameTypeDefaultDescription
densitymx.arrayElectron density rho sampled on the grid.
gridRealSpaceGrid | NoneNoneReal-space grid; required for GGA to evaluate the density gradient. Defaults to None.
density_floorfloat1e-12Lower clamp applied to the density for numerical stability. Defaults to 1e-12.

Returns

  • XCResult — An XCResult with the energy density, potential, and total energy.

Raises

  • ValueError — If grid is None (a grid is required for GGA).
def density_gradient(rho: mx.array, grid: RealSpaceGrid) -> mx.array

Return ∇ρ (shape (3, *grid.shape)) via reciprocal-space differentiation.

Parameters

NameTypeDefaultDescription
rhomx.array
gridRealSpaceGrid

Returns

  • mx.array