xnn.gnn.models.base.GNNPotential#
- class xnn.gnn.models.base.GNNPotential(species, cutoff)[source]#
Bases:
InteratomicPotentialSpecies bookkeeping shared by every GNN potential in this package.
Handles what all graph potentials need regardless of angular basis: an atomic-number -> element-index lookup table, one-hot species node attributes, and the per-element reference energy
atom_ref. The spherical-harmonic models subclass it viaEquivariantGNN;CACE(Cartesian angular basis) subclasses it directly.- Parameters:
- Variables:
z_to_index (Tensor) – Registered long buffer of shape
(200,)mapping atomic number to element index (-1for unsupported elements).atom_ref (torch.nn.Embedding) – Per-element reference-energy embedding (200 entries, one scalar each), initialized to zero.
- set_atomic_energies(values)[source]#
Initialise the per-element reference energies
atom_ref.- Parameters:
values (array-like) – One reference energy per entry of
self.species, in order (MACEE0s, NequIPper_species_rescale_shifts).- Raises:
ValueError – If the number of values does not match the number of species.
- Return type:
None
- node_attr(atomic_numbers)[source]#
Build the one-hot species node attributes.
- Parameters:
atomic_numbers (Tensor) – Long tensor of shape
(N,)giving the atomic number of each of theNnodes.- Returns:
One-hot node attributes of shape
(N, n_species), cast to the dtype ofatom_ref. These are the invariantnode_attrinputs consumed by the interaction blocks’ self-connections.- Return type:
Tensor