dig.ggraph3D.utils¶
Utilities under dig.ggraph3D.utils
.
Collect the lengths for each type of chemical bond in given valid molecular geometries. |
|
Calculate the maximum mean discrepancy distance between two sample set. |
|
Calculate the quantum property score of the given molecular geometry with PySCF. |
|
Convert the given molecular geometry to a 2D molecular graph and check if it is chemically valid through valency check with the algorithm in this paper. |
- collect_bond_dists(mols_dict, valid_list, con_mat_list)[source]¶
Collect the lengths for each type of chemical bond in given valid molecular geometries.
- Parameters
mol_dicts (dict) – A python dict where the key is the number of atoms, and the value indexed by that key is another python dict storing the atomic number matrix (indexed by the key ‘_atomic_numbers’) and the coordinate tensor (indexed by the key ‘_positions’) of all generated molecular geometries with that atom number.
valid_list (list) – the list of bool values indicating whether each molecular geometry is chemically valid. Note that only the bond lengths of valid molecular geometries will be collected.
con_mat_list (list) – the list of bond order matrices.
- Return type
dict
a python dict where the key is the bond type, and the value indexed by that key is the list of all bond lengths of that bond.
- compute_mmd(source, target, batch_size=1000, kernel_mul=2.0, kernel_num=5, fix_sigma=None)[source]¶
Calculate the maximum mean discrepancy distance between two sample set. This implementation is based on this open source code.
- Parameters
source (pytorch tensor) – the pytorch tensor containing data samples of the source distribution.
target (pytorch tensor) – the pytorch tensor containing data samples of the target distribution.
- Return type
- compute_prop(atomic_number, position, prop_name)[source]¶
Calculate the quantum property score of the given molecular geometry with PySCF.
- Parameters
atomic_number (numpy array) – the numpy array indicating the atomic number of atoms in the molecular geometry.
position (numpy array) – the numpy array indicating the coordinates of atoms in the molecular geometry.
prop_name (string) – the name of quantum property, ‘gap’ for HOMO-LUMO gap, ‘alpha’ for isotropic polarizability.
- Return type
- xyz2mol(atoms, coordinates, use_graph=True)[source]¶
Convert the given molecular geometry to a 2D molecular graph and check if it is chemically valid through valency check with the algorithm in this paper.
- Parameters
atoms (numpy array) – the numpy array indicating the atomic number of atoms in the molecular geometry.
coordinates (numpy array) – the numpy array indicating the coordinates of atoms in the molecular geometry.
use_graph (bool) – whether use networkx to compute the maximum-weighted matching of the graph or not. (default:
True
)
- Return type
BO: bond order matrix. valid: a bool value denoting whether the molecular geometry is valid or not.