xnn.common.models.dispersion.gaussian_reference_weights#

xnn.common.models.dispersion.gaussian_reference_weights(cn, refcn, valid, wf, ngw=None, eps_norm=0.0)[source]#

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

D3 paper eq 16 / D4 paper eq 8: W_ref = sum_j^{N_ref} exp(-wf j (CN - CN_ref)^2) / norm. When every Gaussian underflows (a coordination number far from all references) the reference(s) with the largest CN get weight one, as the reference codes do.

Parameters:
  • cn (Tensor) – Coordination numbers, shape (N,).

  • refcn (Tensor) – Reference coordination numbers per atom, shape (N, R).

  • valid (Tensor) – Boolean mask of the used reference slots, shape (N, R).

  • wf (float) – Gaussian exponent (D3: 4, D4: 6).

  • ngw (Tensor or None, optional) – Number of Gaussians per reference (D4’s N^s), shape (N, R); None (D3) uses a single Gaussian per reference.

  • eps_norm (float, optional) – Norm below which the fallback applies (D4 uses sqrt(tiny), D3 exactly zero).

Returns:

Weights, shape (N, R), zero in unused slots.

Return type:

Tensor