xnn.common.models.registry.add_dispersion#

xnn.common.models.registry.add_dispersion(model, spec)[source]#

Wrap model in a D3 or D4 dispersion correction.

The same hook build_model() applies for extra["dispersion"], exposed so deployment code can add dispersion to a trained model after its weights are loaded.

Parameters:
  • model (InteratomicPotential or None) – The short-range model to correct (None for pure dispersion).

  • spec (dict, str or True) – {"name": "d4" | "d3", **options} with the options of DFTD4 / DFTD3; a bare name string; or True for the PBE0-D4 defaults.

Returns:

D4Dispersion or D3Dispersion around model.

Return type:

DispersionCorrection

Raises:

KeyError – For a dispersion name other than "d3" or "d4".