Sublattice#

Implementation of Sublattice class.

A sublattice represents a set of sites in a supercell that all have the same domain/site space. More rigourously it represents a substructure of the random structure supercell being sampled in a Monte Carlo simulation.

class Sublattice(site_space, sites)[source]#

Bases: MSONable

Sublattice class.

A Sublattice is used to represent a subset of supercell sites that have the same site space. Rigorously it represents a set of sites in a “substructure” of the total structure.

As implemented in the Sublattice class, you are allowed to have multiple species on an inactive sub-lattice, but it is not the suggested approach. For simplicity, especially when you generate a CompositionSpace, you had better always split inactive sub-lattices until each inactive sub-lattice have only 1 species in it.

site_space#

SiteSpace with the allowed species and their random state composition.

Type:

SiteSpace

sites#

array of site indices for all sites in sublattice

Type:

ndarray

active_sites#

array of site indices for all unrestricted sites in the sublattice.

Type:

ndarray

encoding#

array of species encoding in integer indices. By default, will be initialized as range(len(site_space)). Might be different if a sub-lattice was created from the split of another sub-lattice.

Type:

ndarray

active_sites: array#
as_dict()[source]#

Get Json-serialization dict representation.

Returns:

MSONable dict

property composition#

Get composition of sublattice.

encoding: array#
classmethod from_dict(d)[source]#

Instantiate a sublattice from dict representation.

Returns:

Sublattice

property is_active#

Whether sub-lattice has active sites.

reset_restricted_sites()[source]#

Reset all restricted sites to active.

restrict_sites(sites)[source]#

Restricts (freezes) the given sites.

Once a site is restricted, no Metropolis step can be proposed with it, including flipping, swapping, etc.

Parameters:

sites (Sequence) – indices of sites in the occupancy string to restrict.

property restricted_sites#

Get restricted sites for species.

site_space: SiteSpace#
sites: array#
property species#

Get allowed species for sites in sublattice.

split_by_species(occu, species_in_partitions)[source]#

Split a sub-lattice into multiple by specie.

An example use case might be simulating topotactic Li extraction and insertion, where we want to consider Li/Vac, TM and O as different sub-lattices that can not be mixed by swapping. :type occu: :param occu: An occupancy array to reference with. :type occu: np.ndarray[int] :type species_in_partitions: :param species_in_partitions: Each sub-list contains a few species or encodings of species in

the site space to be grouped as a new sub-lattice, namely, sites with occu[sites] == specie in the sub-list, will be used to initialize a new sub-lattice. Sub-lists will be pre-sorted to ascending order.

Returns:

List[Sublattice]

Return type:

List of split sub-lattices