Cluster
Cluster:
The cluster module defines the Cluster
object (for simple clusters, transition state clusters, and vacancy-base clusters), and a MonteCarloSampler
object with a jit
version.
Cluster expansion module: types necessary to implement cluster expansions of quantities based on crystals.
- class cluster.Cluster(clustersitelist, transition=False, vacancy=False, NOSORT=False)[source]
Class to define (arbitrary) cluster interactions. A cluster is defined as a set of ClusterSites. We don’t implement this using sets, however, because we make a choice of a “reference” site in each cluster, which has a lattice vector of 0, to account for translational invariance.
The flag transition dictates whether the cluster is a transition state cluster or not. The difference with a transition state cluster is that the first two states in the cluster are the initial and final states of the transition, while all of the remaining parts are the cluster.
- __eq__(other)[source]
Test for equality of two clusters. This is a bit trickier than one would expect, since clusters are essentially sets where all of the lattice vectors are shifted by the center of mass of the sites.
- __init__(clustersitelist, transition=False, vacancy=False, NOSORT=False)[source]
Cluster interaction, from an iterable of ClusterSites :param clustersitelist: iterable of ClusterSites :param transition: True if a transition state cluster; cl[0] = initial, cl[1] = final
- __sub__(other)[source]
Subtract a site from a cluster. Had a very specific meaning: if the site is in the cluster, it returns a list of all the other sites, shifted so that the
other
site is at the origin.Needs to be clarified for the case of a transition state.
- Parameters:
other – needs to be a cluster site in the cluster.
- __weakref__
list of weak references to the object
- g(crys, g)[source]
Apply group operation.
- Parameters:
crys – crystal
g – group operation (from crys)
- Return g*cluster:
corresponding to group operation applied to self
- class cluster.ClusterSite(ci, R)[source]
A class corresponding to a site in a cluster.
- Parameters:
ci – (chem, index) of the site
R – lattice vector of the site
- classmethod fromcryscart(crys, cart_pos)[source]
Return a ClusterSite corresponding to Cartesian position
cart_pos
in crystalcrys
- class cluster.MonteCarloSampler(supercell, spectator_occ, clusterexp, enevalues, chem=None, jumpnetwork=(), KRAvalues=0, TSclusters=(), TSvalues=())[source]
An object to maintain state in a supercell, evaluate energies efficiently including “trial” moves. Built from cluster expansions and using a cluster supercell.
Now is able to handle supercells that contain a single vacancy.
- __init__(supercell, spectator_occ, clusterexp, enevalues, chem=None, jumpnetwork=(), KRAvalues=0, TSclusters=(), TSvalues=())[source]
Setup a MonteCarloSampler using a supercell, with a given spectator occupancy, cluster expansion, and energy values for the clusters. Now includes the ability to evaluate a jumpnetwork, which is optional. Because we need to be consistent with our cluster expansion, can only be done at initialization.
- Parameters:
supercell – should be a ClusterSupercell
spectator_occ – vector of occupancies for spectator species (0 or 1), consistent with our supercell
clusterexp – list of sets of cluster interactions
enevalues – energy values corresponding to each cluster
chem – (optional) index of species that transitions
jumpnetwork – (optional) list of lists of jumps; each is ((i, j), dx) where
i
andj
are unit cell indices for specieschem
KRAvalues – (optional) list of “KRA” values for barriers (relative to average energy of endpoints); if
TSclusters
are used, choosing 0 is more straightforward.TSclusters – (optional) list of transition state cluster expansion terms; this is always added on to KRAvalues (thus using 0 is recommended if TSclusters are also used)
TSvalues – (optional) values for TS cluster expansion entries
- __weakref__
list of weak references to the object
- deltaE_trial(occsites=(), unoccsites=())[source]
Compute the energy change if the sites in occsites are occupied, and the sites in unoccsites are unoccupied.
A few notes: the algorithm does not check whether the same site appears in either iterable multiple times; it trusts that the user has provided it with a meaningful trial change.
- Parameters:
occsites – iterable of sites to attempt occupying
unoccsites – iterable of sites to attempt unoccupying
- Return deltaE:
change in energy
- start(occ)[source]
Initialize with an occupancy, and prepare for future calculations.
- Parameters:
occ – occupancy of sites in supercell; assumed to be 0 or 1
- class cluster.MonteCarloSampler_jit(*args, **kwargs)[source]
Numba jit wrapper on a MonteCarloSampler.
- cluster.MonteCarloSampler_param(MCsampler)[source]
Takes in a MCsampler, returns a dictionary of all the parameters for the jit-version
- cluster.makeTSclusters(crys, chem, jumpnetwork, clusterexp)[source]
Function to make TS clusters based on an existing cluster expansion corresponding to a given jump network.
- Parameters:
crys – crystal to construct our clusters for
chem – index of mobile species
jumpnetwork – list of lists of ((i, j), dx) transitions
clusterexp – list of sets of clusters to base TS cluster expansion
- Returns:
TSclusterexp: list of sets of TS clusters
- cluster.makeVacancyClusters(crys, chem, clusterexp)[source]
Function to make vacancy clusters based on an existing cluster expansion where the vacancies live on a particular sublattice.
- Parameters:
crys – crystal to construct our clusters for
chem – index of the sublattice to contain a vacancy
clusterexp – list of sets of clusters to base vacancy cluster expansion
- Returns:
VacClusterexp: list of sets of vacancy clusters
- cluster.makeclusters(crys, cutoff, maxorder, exclude=())[source]
Function to make clusters up to a maximum order involving all sites within a cutoff distance. We can exclude certain chemistries; default is to use all.
- Parameters:
crys – crystal to construct our clusters for
cutoff – distance between sites; all sites in a cluster must have this mutual distance
maxorder – maximum order of our clusters
exclude – list of chemistries to exclude
- Return clusterexp:
list of sets of clusters