Permutation map

The purpose of this example is to demonstrate how to extract a permutation map.

Import modules

To extract permutation maps, only a single icet function is required, namely permutation_matrix_from_atoms. Additionally, the ASE function ase.build.bulk() will be needed to generate a structure.

import numpy as np
from ase.build import bulk
from icet.core.permutation_map import permutation_matrix_from_atoms

Generate prototype Al unit cell

The next step is to build a prototype ASE Atoms object, here an aluminum fcc unit cell.

atoms = bulk('Al', 'fcc', a=2.0)

Obtain a permutation map

Next, the permutation_matrix_from_atoms function is called with the ASE Atoms object that was defined above and a neighbor cutoff of 2.0 Å as arguments. The resulting output is a list that contains three elements, namely a PermutationMap, a primitive Structure and a NeighborList.

neighbor_cutoff = 2.0
permutation_map, prim_structure, neighbor_list = \
    permutation_matrix_from_atoms(atoms, neighbor_cutoff, verbosity=3)

Since the verbosity was set to \(\geq 3\), the following extra information should be printed by permutation_matrix_from_atoms:

size of atoms_prim 1
number of positions: 19

Extract permuted positions

The permuted as well as the indexed and unique positions can be extracted from the PermutationMap object, generated earlier, using the methods PermutationMap.get_permuted_positions() and PermutationMap.get_indiced_positions(), respectively.

perm_pos = permutation_map.get_permuted_positions()
ind_pos, unique_pos = permutation_map.get_indexed_positions()

Source code

The complete source code is available in examples/get_permutation_map.py
'''
This example generate a permutation map for a structure
'''

# Import modules
import numpy as np
from ase.build import bulk
from icet.core.permutation_map import permutation_matrix_from_atoms

# Create a prototype Al structure
atoms = bulk('Al', 'fcc', a=2.0)

# Generate a permutation map (matrix) for all neighbors inside the cutoff
neighbor_cutoff = 2.0
permutation_map, prim_structure, neighbor_list = \
    permutation_matrix_from_atoms(atoms, neighbor_cutoff, verbosity=3)

# Extract the permuted, indexed and unique positions.
perm_pos = permutation_map.get_permuted_positions()
ind_pos, unique_pos = permutation_map.get_indexed_positions()

# Print the permuted, indexed and unique positions.
print('Permutated fractional coordinates')
for pp in perm_pos:
    unique_rows = np.vstack({tuple(row) for row in pp})
    for el in unique_rows:
        print(el, end=' ')
    print('')
print('Permutated indices and positions')
for i, pos in enumerate(ind_pos):
    print(i, len(set(pos)), pos)
print('Unique permuted indices and positions')
for index, dist in enumerate(unique_pos):
    print(index, dist)