Native clusters

The purpose of this example is to demonstrate how to extract native clusters.

Import modules

In the present case it is necessary to import two icet classes, namely ClusterSpace and Structure. The respective objects are used to store information regarding a specific cluster space and structure. Additionally, the ASE function ase.build.bulk() will be used to generate the structures.

import numpy as np
from ase.build import bulk
from icet import ClusterSpace, Structure

Generate prototype Si cell

The next step is to build a prototype, here a unit cell of bulk silicon. It is furthermore decided that the cluster vectors will be created by populating the sites with either silicon or germanium. Also the cutoff for pairs is set to 10 Å.

conf = bulk('Si')
cutoffs = [10.0]
subelements = ['Si', 'Ge']

Initiate the cluster space

The cluster space is created by initiating a ClusterSpace object and providing the prototype structure, cutoffs and list of elements that were defined above as arguments.

cluster_space = ClusterSpace(conf, cutoffs, subelements)

Structure from Si/Ge supercell

First, a \(2\times2\times1\) supercell is built, after which the sites are randomly populated with Si and Ge atoms. Thereafter, an icet Structure object structure is created by providing an ASE Atoms object as input to the Structure.from_atoms() method.

supercell = bulk('Si').repeat([2, 2, 1])
for atom in supercell:
    atom.symbol = np.random.choice(subelements)
structure = Structure.from_atoms(supercell)

Extract the native clusters

The native clusters are extracted with help of the ClusterSpace.get_native_clusters method, with the structure defined in the previous section as input argument. Afterwards the structure itself and the native clusters are printed in tabular format, in the latter case by using the print() method.

native_clusters = cluster_space.get_native_clusters(structure)
print(structure)
print('\nNative cluster counts:')
native_clusters.print()

The (partial) output produced by this script should similar to the following:

Cell:
[[ 0.     5.43   5.43 ]
 [ 5.43   0.     5.43 ]
 [ 2.715  2.715  0.   ]]

Element and positions:
 Si  [ 0.  0.  0.]
 Ge  [ 1.3575  1.3575  1.3575]
 Si  [ 2.715  0.     2.715]
 Si  [ 4.0725  1.3575  4.0725]
 Si  [ 0.     2.715  2.715]
 Ge  [ 1.3575  4.0725  4.0725]
 Ge  [ 2.715  2.715  5.43 ]
 Si  [ 4.0725  4.0725  6.7875]

Native cluster counts:
5.91721  :: 0 0 2.9586
==============
Si Si 3
Si Ge 1
Total: 4
...
 :: 0 0
==============
Si 5
Ge 3
Total: 8

Source code

The complete source code is available in examples/get_native_clusters.py
'''
This example demonstrates how to find the native clusters for a structure
'''

# Import modules
import numpy as np
from ase.build import bulk
from icet import ClusterSpace, Structure

# Create a prototype structure, decide which additional elements to populate
# it with (Si, Ge) and set the cutoff for pairs (10.0 A)
conf = bulk('Si')
cutoffs = [10.0]
subelements = ['Si', 'Ge']

# Initiate the cluster space.
cluster_space = ClusterSpace(conf, cutoffs, subelements)

# Prepare 2x2x1 supercells, populate these, randomly, with Si and Ge atoms.
supercell = bulk('Si').repeat([2, 2, 1])
for atom in supercell:
    atom.symbol = np.random.choice(subelements)
structure = Structure.from_atoms(supercell)

# Extract and print the native clusters for the supercell.
native_clusters = cluster_space.get_native_clusters(structure)
print(structure)
print('\nNative cluster counts:')
native_clusters.print()