xnn.gnn.models.qet.QET#
- class xnn.gnn.models.qet.QET(n_features=64, n_interactions=2, n_rbf=32, cutoff=5.0, radial_basis='gaussian', trainable_rbf=False, activation='silu', equivariance_group='O(3)', n_elements=128, energy_shift=0.0, energy_scale=1.0, species=None, atomic_energies=None, readout='gated', readout_hidden=None, self_pairs=False, rbf_max=None, gamma=None, hardness='element', trainable_widths=False)[source]#
Bases:
TensorNetQET interatomic potential: TensorNet with analytic charge equilibration.
See the module docstring for the equations. The options of
TensorNetkeep their meaning; the defaults follow the authors’ code.- Parameters:
n_features (int, optional) – Number of tensor features
F, by default 64.n_interactions (int, optional) – Number of interaction layers, by default 2.
n_rbf (int, optional) – Number of radial basis functions, by default 32.
cutoff (float, optional) – Neighbor-list radius, cosine cutoff of the trunk and range of the Coulomb potential (Angstrom), by default 5.0.
radial_basis (str, optional) – Any basis of
make_radial_basis(), by default"gaussian".trainable_rbf (bool, optional) – Learn the parameters of the basis, by default
False.activation (str, optional) – Nonlinearity of the trunk, the electronegativity network and the energy network, by default
"silu".equivariance_group (str, optional) –
"O(3)"(default) or"SO(3)".n_elements (int, optional) – Size of the per-element tables, indexed by
Z, by default 128.energy_shift (float, optional) – Per-atom energy standardization, by default 0 and 1.
energy_scale (float, optional) – Per-atom energy standardization, by default 0 and 1.
species (list of int or None, optional) – Only used to interpret
atomic_energies.atomic_energies (array-like or None, optional) – Per-species reference energies loaded into
atom_ref.readout (str, optional) – The atom-wise energy network,
"gated"(default) or"mlp".readout_hidden (sequence of int or None, optional) – Hidden widths of the energy network; by default
(F + 2, F, F)for"gated".self_pairs (bool, optional) – Whether every atom is its own neighbor in the trunk, by default
False.rbf_max (float or None, optional) – Position of the last Gaussian of the
"gaussian"basis;None(default) iscutoff + 1.gamma (float or None, optional) – Exponent of the Gaussians,
exp(-gamma (r - mu)^2);None(default) is 0.5.hardness (str, optional) –
"element"(default; one learned hardness per element) or"environment"(a softplus network of the atom’s features, as in the paper).trainable_widths (bool, optional) – Learn the Gaussian charge widths per element (initialized to one) instead of using the covalent radii, by default
False.
- Variables:
chi_readout (xnn.common.models.blocks.MLP) – The electronegativity network.
hardness_readout (torch.nn.Module) – The hardness, per element or per environment.
sigma (torch.Tensor) – Gaussian charge widths per element (Angstrom), indexed by
Z.coulomb_cutoff (xnn.common.featurizers.PolynomialCutoff) – The envelope of the Coulomb potential.
readout_norm (torch.nn.LayerNorm) – Layer norm of
[h_i, q_i, V_i].
- readout_extra_inputs = 2#
Per-atom inputs of the energy network besides the
Ffeatures (a subclass’s own).
- receptive_field()[source]#
None: the charge constraint couples every atom of a structure.- Return type:
float | None
- node_features_energy_charges(atomic_numbers, edge_index, edge_vec, pos, cell, pbc, total_charge, spin_multiplicity)[source]#
TorchScript core of one structure: features, atomic energies and charges.
- Parameters:
atomic_numbers (Tensor) – Per-atom atomic numbers
(N,).edge_index (Tensor) – Edge index
(2, E); row 0 the neighbor, row 1 the center.edge_vec (Tensor) – Edge vectors
(E, 3).pos (Tensor) – Unused (part of the shared ABI).
cell (Tensor) – Unused (part of the shared ABI).
pbc (Tensor) – Unused (part of the shared ABI).
total_charge (float) – Net charge of the structure.
spin_multiplicity (float) – Unused.
- Returns:
The trunk’s invariant features
(N, F), the per-atom energy(N,)and the charges(N,).- Return type:
tuple of Tensor
- node_features_energy(atomic_numbers, edge_index, edge_vec)[source]#
TorchScript core of one neutral structure: features and per-atom energies.
- forward(data)[source]#
Energies and charges of a batched graph.
- Parameters:
data (AtomicGraph) – Batched atomic graph; its
total_charge(per structure, zero when absent) andexternal_potential(per atom, none when absent) enter the charge equilibration.- Returns:
"node_energy"(N,),"energy"(B,),"charges"(N,),"electrostatic_potential"(N,)(the Coulomb potentialV_iin V),"node_features"(the trunk’s invariant features,(N, F)) and"node_tensors"((N, 3, 3, F)).- Return type:
dict of str to Tensor
- classmethod from_foundation(name='qet-matpes-pbe-2025.2', dtype=None, cache_dir=None)[source]#
Load a MatGL QET foundation potential (MatPES PBE or r2SCAN).
See
xnn.gnn.models.qet_foundation.- Parameters:
name (str, optional) –
"qet-matpes-pbe-2025.2"(default) or"qet-matpes-r2scan-2025.2".dtype (torch.dtype or str, optional) – Final dtype;
Nonekeeps the checkpoint’s float32.cache_dir (str or pathlib.Path, optional) – Model cache directory.
- Returns:
The converted potential, in evaluation mode.
- Return type:
- classmethod from_config(cfg)[source]#
Build a
QETfrom a configuration object.Core fields:
cfg.n_features,cfg.n_interactions,cfg.n_rbf,cfg.cutoff. Everything else is read fromcfg.extra: the options ofTensorNet.from_configandhardness,trainable_widths; MatGL’s key spellings are translated byxnn.common.config.translate.- Parameters:
cfg (xnn.common.config.schema.ModelConfig) – The core model config.
- Returns:
Instantiated model.
- Return type: