xnn.dnn.featurizers.symmetry_functions.RadialSymmetryFunctions#

class xnn.dnn.featurizers.symmetry_functions.RadialSymmetryFunctions(species, cutoff=6.0, etas=(0.05, 0.5, 2.0, 8.0), rs=(0.0,), prefactor=1.0)[source]#

Bases: FastPathModule, Featurizer

Behler G2 radial symmetry functions, resolved by neighbour species.

Computes G2_i = pref * sum_j exp(-eta (r_ij - Rs)^2) fc(r_ij) for each central atom i, over a grid of (eta, Rs) parameters and bucketed by the chemical species of the neighbour j, giving an invariant per-atom descriptor with chemical awareness.

Parameters:
  • species (list[int]) – Atomic numbers the descriptor resolves neighbours into (one bucket per species).

  • cutoff (float, optional) – Cutoff radius for the cosine cutoff, by default 6.0.

  • etas (sequence of float, optional) – Width parameters of the radial Gaussians, by default (0.05, 0.5, 2.0, 8.0).

  • rs (sequence of float, optional) – Radial shifts Rs of the Gaussians, by default (0.0,).

  • prefactor (float, optional) – Constant multiplying every term. 1.0 (Behler-Parrinello, default) or 0.25 (ANI / NeuroChem / torchani convention).

Variables:
  • species (list[int]) – The resolved neighbour species.

  • cutoff (float) – Cutoff radius.

  • z_to_idx (dict[int, int]) – Mapping from atomic number to its species bucket index.

  • cutoff_fn (CosineCutoff) – Smooth cutoff function applied to each edge.

fast_supported(device, dtype)[source]#

Triton on device (the fused kernels of xnn.dnn.fast.aev).

Parameters:
Return type:

bool

property output_dim: int#

Descriptor length, n_params * n_species (n_eta * n_rs parameters per species bucket).

Type:

int

edge_terms(r, weight)[source]#

The terms weight * exp(-eta (r - Rs)^2) of every edge, (E, n_params).

Parameters:
  • r (Tensor) – Edge lengths (E,).

  • weight (Tensor) – Factor of every edge (E,): the prefactor times the cutoff function for the descriptor.

Returns:

The terms, ordered (eta, Rs) like torchani’s (EtaR, ShfR).

Return type:

Tensor

forward(data)[source]#

Compute the radial symmetry-function descriptor.

Parameters:

data (AtomicGraph) – Atomic graph providing atomic numbers, edge index and edge vectors.

Returns:

Per-atom radial descriptor of shape (N, output_dim).

Return type:

Tensor

compute(atomic_numbers, edge_index, edge_vec, num_nodes, r=None)[source]#

forward() on tensors: atomic numbers (N,), edges (2, E), edge vectors (E, 3) and optionally their lengths (E,) (TorchScript-compatible).

Parameters:
Return type:

Tensor