nvalchemi.csp.chem.build_contact_distance_matrix#
- nvalchemi.csp.chem.build_contact_distance_matrix(molecules, *, device='cpu')[source]#
Build intermolecular contact cutoffs used to measure overlap.
- Parameters:
molecules (sequence of rdkit.Chem.rdchem.Mol) – Nonempty connected components in formula-unit order. Atom order is preserved, and no conformers are needed.
device (torch.device or str, default="cpu") – Device for the returned matrix; contact rules are evaluated on CPU.
- Returns:
Owned symmetric contact cutoffs in angstroms. Entry
[i, j]defines overlap between atomsiandjin different molecular copies; distances within one rigid molecule are not measured against this matrix.OverlapReliefPackermay accept residual overlap up toOverlapReliefConfig.overlap_tolerance.- Return type:
torch.Tensor, shape
[A, A], dtypetorch.float32- Raises:
OptionalDependencyError – If RDKit is unavailable. Install
nvalchemi-toolkit[rdkit].TypeError – If
moleculesis not a sequence of RDKit molecules.ValueError – If the sequence is empty, a molecule is disconnected, or an element has no positive RDKit fallback van der Waals radius.
Notes
Defaults begin with van der Waals radius sums and apply the strongest symmetric donor/acceptor reduction, capped at 0.90 angstroms. The rules include hydrogen, halogen, chalcogen, phosphorus, silicon, and boron cases. Known element radii are built in; using RDKit’s periodic-table fallback emits a
RuntimeWarning. These experimental chemistry rules and values may change in a future release.Examples
This methanol input has carbon and oxygen atoms; its implicit hydrogens have no separate rows in the matrix. The C-O entry applies to atoms in different copies, not to the C-O bond inside one methanol molecule.
>>> from rdkit import Chem >>> molecule = Chem.MolFromSmiles("CO") >>> contacts = build_contact_distance_matrix([molecule]) >>> tuple(contacts.shape) (2, 2) >>> round(float(contacts[0, 1]), 2) 3.27