Cluster#

class libcasm.clusterography.Cluster(
self: Cluster,
sites: collections.abc.Sequence[IntegralSiteCoordinate],
)#

Bases: pybind11_object

A cluster of IntegralSiteCoordinate

Special Methods

The multiplication operator X = lhs * rhs can be used to apply libcasm.xtal.IntegralSiteCoordinateRep to Cluster:

  • X=Cluster, lhs=IntegralSiteCoordinateRep, rhs=Cluster: Copy and transform all sites in the cluster, returning the cluster of transformed sites, such that X.site(i) == lhs * rhs.site(i), for all valid i.

Translate a Cluster using operators +, -, +=, -=:

import numpy as np
from libcasm.clusterography import Cluster

# construct Cluster
cluster = Cluster.from_list(
    [
        [0, 0, 0, 0], # [b, i, j, k]
        [0, 1, 0, 0],
    ]
)
translation = np.array([0, 0, 1])

# translate via `+=`:
cluster += translation

# translate via `-=`:
cluster -= translation

# copy & translate via `+`:
translated_cluster = cluster + translation

# copy & translate via `-`:
translated_cluster = cluster - translation

Sort Cluster by lexicographical order of their sites using <, <=, >, >=, and compare using ==, !=:

import numpy as np
from libcasm.clusterography import Cluster

# construct Cluster
A = Cluster.from_list(
    [
        [0, 0, 0, 0], # [b, i, j, k]
        [0, 1, 0, 0],
    ]
)
B = Cluster.from_list(
    [
        [0, 0, 0, 0], # [b, i, j, k]
        [0, 0, 1, 0],
    ]
)

assert A < B
assert A <= B
assert A <= A
assert B > A
assert B >= A
assert B >= B
assert A == A
assert B == B
assert A != B

Additional methods:

  • for site in cluster: Iterate over sites (IntegralSiteCoordinate) in the cluster.

  • if site in cluster: Check if a cluster contains a site.

  • len(cluster): Get the number of sites in a cluster.

  • site = cluster[i]: Get the i-th site in a cluster (indices start at 0).

  • Cluster may be copied with Cluster.copy, copy.copy, or copy.deepcopy.

Constructor

Parameters:

sites (List[IntegralSiteCoordinate]) – List of sites in the cluster. May be empty.

Methods

append(…)

Overloaded function.

copy(…)

Returns a copy of the Cluster.

distances(…)

Return cluster site-to-site distances

from_dict(…)

Construct an Cluster from a Python dict

from_list(…)

Construct a Cluster from a list of sites (as [b, i, j, k])

is_sorted(…)

Return True if the cluster sites are sorted; False otherwise.

phenomenal_distances(…)

Return phenomenal cluster site to cluster site distances

site(…)

Returns the i-th site in the cluster

sites(…)

Returns the cluster sites

size(…)

Returns number of sites in the cluster

sort(…)

Sort cluster sites

sorted(…)

Return a copy of the cluster with sites sorted

to_dict(…)

Represent the Cluster as a Python dict

to_index_list(…)

Convert Cluster to a list of linear site indices in a supercell

to_index_set(…)

Convert Cluster to a set of linear site indices in a supercell

to_list(…)

Returns the cluster sites as a list of sites (as [b, i, j, k])