matador.plugins.voronoi_interface package¶
Submodules¶
matador.plugins.voronoi_interface.voronoi_interface module¶
This file implements a thin wrapper to the Voronoi code written by Can Kocer, for use with matador queries and docs.
https://bitbucket.org/can_kocer/ajm_group_voronoi_code
Requires Can’s code to be on your PYTHONPATH.
matador.plugins.voronoi_interface.voronoi_similarity module¶
This file implements lattice-site level measures of similarity, using Voronoi decompositions.
Sketch of methodology:
For a list of structures, take each in turn, compute the Voronoi substructure
and create normalised padded arrays so that they can be compared.
For each structure, find the unique sites, to some definition of unique, initially
just a simple np.isclose() on the site arrays.
Now do an all-to-all comparison of the unique sites in each structure, yielding
an overall list of unique substructures. This step should have a dial that can be turned such that all sites fold onto each other, or all sites become distinct, i.e. sensitivity vs specificity.
[OPTIONAL] The remaining unique sites across the whole list can now be clustered, if desired,
using e.g. hierarchical clustering.
Every site in every structure can now be assigned to one of the unique sites above, or
one of the unique clusters.
Finally, the structures themselves can be clustered by the sites that are present, if desired.
- matador.plugins.voronoi_interface.voronoi_similarity.are_sites_the_same(site_A, site_B, rtol=0.01, atol=0.01)[source]¶
Simple check for uniqueness of sites based on their Voronoi substructure.
Input:
site_A : dict, with elements as keys, containing numpy arrays of normalised solid angles.site_B : dict, as A.- Parameters:
rtol (|) – relative tolerance in solid angle for np.allclose,
atol (|) – absolute tolerance in solid angle for np.allclose.
- Returns:
- True if sites have approximately the same values for each species, else False.
- matador.plugins.voronoi_interface.voronoi_similarity.collect_unique_sites(cursor)[source]¶
Collect unique substrucs from each structure into a single dict.
Input:
cursor: list(dict), list of structures with pre-computed unique sites.- Returns:
- dict(list), dict with element symbol keys containing
a list of each unique substructure.
- Return type:
- unique_environments
- matador.plugins.voronoi_interface.voronoi_similarity.get_max_coordination_of_elem(single_elem_environments)[source]¶
For a given set of elemental environments, find the greatest number of each element in a site.
Input:
single_elem_environments: list(dict), list of voronoi substructures,- Returns:
dict(int), greatest number of each element in a substruc.
- Return type:
- max_num_elem
- matador.plugins.voronoi_interface.voronoi_similarity.create_site_array(unique_environments, max_num_elems=None, elems=None, normalise=False)[source]¶
Create padded numpy arrays based on unique environments provided.
Input:
unique_environments: dict(list), dict with element keys full of local substructures.- Parameters:
max_num_elems (|) – dict(dict(int)), dict with element keys, containing sub-dict with element keys that contain the largest number of each type of element contributing to a site. If None, this will be calculated based on the input environments. The site array is padded to this size.
elems (|) – list(str), custom list of elements to loop over.
normalise (|) – bool, whether to normalise site array to 1.
- Returns:
- dict(np.ndarray), dict with element keys full of
normalised site arrays.
max_num_elems : dict(dict(int)), dict with element keys containing the highest number of atoms of an element contributing to a particular site, e.g. {‘P’: {‘K’: 10}}.- Return type:
- site_array
- matador.plugins.voronoi_interface.voronoi_similarity.set_substruc_dict(doc)[source]¶
Compute voronoi substructure and collect into dict. Sets the ‘voronoi_substruc’ and ‘substruc_dict’ entries in the doc.
Input:
doc: dict, structure to compute substructure of.
- matador.plugins.voronoi_interface.voronoi_similarity.set_site_array(doc, normalise=False)[source]¶
Set the ‘site_array’ entry in the chosen document. Creates a dict of numpy arrays of normalised solid angles with element keys from the import calculated substructure.
Input:
doc: dict, matador doc containing substruc_dict.- Parameters:
normalise (|) – bool, whether to normalise site_arrays to total angle.
- matador.plugins.voronoi_interface.voronoi_similarity.get_unique_sites(doc, atol=0.01, rtol=0.01)[source]¶
- matador.plugins.voronoi_interface.voronoi_similarity.cluster(X, hull, max_of_elems, elems=None, method='KMeans', elem='P', quantile=None, n_clusters=None, cmap='tab10')[source]¶