xnn.common.models.dispersion#

Shared machinery of the dispersion add-ons (DFT-D3, DFT-D4).

The two Grimme dispersion models share most of their structure: a real-space cutoff with an optional quintic switching window, Gaussian coordination-number weights over tabulated reference systems (D3 paper eq 16, D4 paper eq 8), an Axilrod-Teller-Muto three-body term with zero damping over the atom triples of a neighbor list (D3 paper eqs 11-14, D4 paper eqs 22-27), and the same way of attaching themselves to a short-range model. Those pieces live here, once; d3 and d4 hold what is specific to each model (the coordination-number counting function, the reference data, the damping functions, D4’s charge scaling and EEQ charges).

DispersionCorrection is the model-agnostic wrapper both add-ons derive from: standalone it is the dispersion energy, given a short-range model it adds the dispersion energy to that model’s prediction while handing the model only the edges within its own cutoff. The deploy channels (torchscript, lammps) peel the wrapper off through the same interface.

Functions

evaluate_on_graph(term, data)

Run a dispersion term's evaluate on a (batched) AtomicGraph.

gaussian_reference_weights(cn, refcn, valid, wf)

Normalized Gaussian weights of the reference systems in the coordination number.

options_from_extra(extra, keys)

Pick the recognized keyword arguments out of a config extra dict.

switching_function(r, cutoff, width)

Quintic switching window: 1 below cutoff - width, 0 above cutoff.

three_body_energy(z, edge_index, edge_vec, ...)

Per-atom Axilrod-Teller-Muto three-body energy with zero damping.

Classes

DispersionCorrection(term[, model])

A dispersion term as an xnn potential, standalone or wrapped around a model.