Skip to content

dft.gga

PBE-form 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-pz81-gga-alpha')

Alpha PBE-form GGA exchange-correlation with a PZ81 uniform baseline.

The exchange enhancement and correlation gradient terms follow the PBE form, while the uniform-gas correlation baseline reuses the PZ81 parameterization already in the package. Full production PBE uses a PW92 baseline, so this public alpha class intentionally reports an explicit alpha result name.

Parameters

NameTypeDefaultDescription
namestr'pbe-pz81-gga-alpha'

Methods

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

Evaluate alpha PBE-form GGA 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).
class ProductionPBEExchangeCorrelation
def __init__(name: str = 'pbe-pw92-gga')

PBE GGA exchange-correlation with the PW92 uniform-gas baseline.

Parameters

NameTypeDefaultDescription
namestr'pbe-pw92-gga'

Methods

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

Evaluate production PBE energy density, potential, and total energy.

Parameters

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

Returns

  • XCResult — Production PBE energy density, potential, and total energy.

Raises

  • ValueError — If no real-space grid is provided.
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