xnn.common.models.dispersion.DispersionCorrection#
- class xnn.common.models.dispersion.DispersionCorrection(term, model=None)[source]#
Bases:
InteratomicPotentialA dispersion term as an xnn potential, standalone or wrapped around a model.
Standalone (
model=None) the potential is the dispersion energy alone; given a short-rangemodelit adds the dispersion energy to that model’s prediction: the wrapper’scutoffis the larger of the model’s and the term’s cutoffs (the neighbor-list radius the data pipeline uses), and the wrapped model only ever sees the edges within its own cutoff.D4DispersionandD3Dispersionare the two instances; enable either from a config withmodel.extra["dispersion"](seebuild_model()).- Parameters:
term (torch.nn.Module) – The dispersion evaluator (
DFTD4orDFTD3): exposescutoff(Angstrom) andevaluate(atomic_numbers, pos, edge_index, edge_vec, batch, num_graphs, cell, pbc, total_charge)returning at least"node_energy"(eV),"energy_2body","energy_3body","coordination_numbers"and"node_features".model (InteratomicPotential or None, optional) – The short-range model to correct;
Nonefor pure dispersion.
- Variables:
term (torch.nn.Module) – The dispersion evaluator.
model (InteratomicPotential or None) – The wrapped model.
cutoff (float) – Neighbor-list radius (Angstrom):
max(model.cutoff, term.cutoff).node_feature_dim (int) – The wrapped model’s feature width, or the term’s own per-atom descriptors standalone (so LES can wrap a pure dispersion model too).
Notes
forwardreturns the combined"energy"/"node_energy"and adds"energy_sr"(the wrapped model’s energy),"energy_disp","energy_2body","energy_3body"(B,)and the term’s per-atom quantities ("coordination_numbers", and for D4"eeq_charges","polarizabilities","dynamic_polarizabilities"; for D3"c6_matrix"). The total charge of each structure is read fromdata.total_charge((B,); zero when absent).- inner_graph(data)[source]#
datarestricted to the edges within the wrapped model’s cutoff.- Parameters:
data (AtomicGraph)
- Return type:
- dispersion(data)[source]#
Evaluate the dispersion term on a (batched) graph; see
evaluate_on_graph().- Parameters:
data (AtomicGraph)
- Return type:
- forward(data)[source]#
Wrapped-model prediction plus the dispersion energy.
- Parameters:
data (AtomicGraph) – The batched graph, built with this wrapper’s
cutoff.- Returns:
See the class notes.
- Return type:
dict of str to Tensor