Cluster#
Implementation of the Cluster class.
Represents a group of sites of a given lattice. These are the building blocks for a cluster basis of functions over configurational space.
- class Cluster(site_spaces, frac_coords, lattice)[source]#
Bases:
SiteCollection
,MSONable
An undecorated (no occupancies) cluster.
Represented simply by a list of sites, its centroid, and the underlying lattice.
You probably never need to instantiate this class directly. Look at ClusterSubspace to create orbits and clusters necessary for a CE.
- frac_coords#
fractional coordinates of each site.
- Type:
ndarray
- lattice#
Underlying lattice of cluster.
- Type:
Lattice
- centroid#
Geometric centroid of included sites.
- Type:
float
- id#
ID of cluster. Used to identify the Cluster in a given ClusterSubspace.
- Type:
int
Initialize Cluster.
- Parameters:
site_spaces (list of SiteSpace) – list of site spaces for the cluster
frac_coords (Sequence) – Sequence of frac coords for the site spaces
lattice (Lattice) – pymatgen Lattice object
- property centroid#
Return the centroid of cluster.
- property diameter#
Get maximum distance between any 2 sites in the cluster.
- property frac_coords#
Return the fractional coordinates of cluster w.r.t the underlying lattice.
- classmethod from_file(filename)[source]#
Read a cluster from a file. Supported formats are json and yaml only.
- Parameters:
filename (str) – The filename to read from.
- Returns:
Cluster
- classmethod from_sites(sites, lattice)[source]#
Create a cluster from a list of sites and lattice object.
- classmethod from_str(input_string, fmt)[source]#
Read a cluster from a string.
- Parameters:
input_string (str) – String to parse.
fmt (str) – Format to output to. Defaults to JSON unless filename is provided. If fmt is specifies, it overrides whatever the filename is. Options include “yaml”, “json”. Non-case sensitive.
- Returns:
Cluster
- get_distance(i, j)[source]#
Return distance between sites at index i and j.
- Parameters:
i (
int
) – Index of first sitej (
int
) – Index of second site
- Return type:
float
- Returns:
Distance between sites at index i and index j.
- property lattice#
Return the underlying lattice.
- property radius#
Get half the maximum distance between any 2 sites in the cluster.
- property sites#
Return the list of sites.
- to(fmt=None, filename=None)[source]#
Output the cluster to a file or string.
this is basically a watered down version of pymatgen.Molecule.to
- Parameters:
fmt (str) –
Format to output to. Defaults to JSON unless filename is provided. If fmt is specifies, it overrides whatever the filename is. Options include “yaml” and “json” only.
Non-case sensitive.
filename (str) – If provided, output will be written to a file. If fmt is not specified, the format is determined from the filename. Defaults is None, i.e. string output.
- Returns:
(str) if filename is None. None otherwise.