# Dimensionality analysis¶

This is a example of analysis of the dimensionality of a structure using the ase.geometry.dimensionality.analyze_dimensionality() function. This is useful for finding low-dimensional materials, such as 1D chain-like structures, 2D layered structures, or structures with multiple dimensionality types, such as 1D+3D.

The example below creates a layered MoS2 structure and analyzes its dimensionality.

import ase.build
from ase.visualize import view
from ase.geometry.dimensionality import analyze_dimensionality

atoms = ase.build.mx2(formula='MoS2', kind='2H', a=3.18, thickness=3.19)
atoms.cell[2, 2] = 7.0
atoms.set_pbc((1, 1, 1))
atoms *= 3

intervals = analyze_dimensionality(atoms, method='RDA')
m = intervals[0]
print(sum([e.score for e in intervals]))
print(m.dimtype, m.h, m.score, m.a, m.b)

atoms.set_tags(m.components)
view(atoms)


Coloring the atoms by their tags shows the distinct bonded clusters, which in this case are separate layers.

Each component in the material can be extracted, or “isolated”, using the ase.geometry.dimensionality.isolate_components() function as the example below demonstrates.

import numpy as np
import ase.build
from ase import Atoms
from ase.visualize import view
from ase.geometry.dimensionality import isolate_components

# build two slabs of different types of MoS2
rep = [4, 4, 1]
a = ase.build.mx2(formula='MoS2', kind='2H', a=3.18, thickness=3.19) * rep
b = ase.build.mx2(formula='MoS2', kind='1T', a=3.18, thickness=3.19) * rep
positions = np.concatenate([a.get_positions(), b.get_positions() + [0, 0, 7]])
numbers = np.concatenate([a.numbers, b.numbers])
cell = a.cell
atoms = Atoms(numbers=numbers, positions=positions, cell=cell, pbc=[1, 1, 1])
atoms.cell[2, 2] = 14.0

# isolate each component in the whole material
result = isolate_components(atoms)
print("counts:", [(k, len(v)) for k, v in sorted(result.items())])

for dim, components in result.items():
for atoms in components:
print(dim)
view(atoms, block=True)


The method is described in the article:

P.M. Larsen, M. Pandey, M. Strange, and K. W. Jacobsen
Phys. Rev. Materials 3 034003, 2019

A preprint is available here.

ase.geometry.dimensionality.analyze_dimensionality(atoms, method='RDA', merge=True)

Performs a k-interval analysis.

In each k-interval the components (connected clusters) are identified. The intervals are sorted according to the scoring parameter, from high to low.

Parameters:

atoms: ASE atoms object

The system to analyze. The periodic boundary conditions determine the maximum achievable component dimensionality, i.e. pbc=[1,1,0] sets a maximum dimensionality of 2.

method: string

Analysis method to use, either ‘RDA’ (default option) or ‘TSA’. These correspond to the Rank Determination Algorithm of Mounet et al. and the Topological Scaling Algorithm (TSA) of Ashton et al.

merge: boolean

Decides if k-intervals of the same type (e.g. 01D or 3D) should be merged. Default: true

Returns:

intervals: list

List of KIntervals for each interval identified. A KInterval is a namedtuple with the following field names:

score: float

Dimensionality score in the range [0, 1]

a: float

The start of the k-interval

b: float

The end of the k-interval

dimtype: str

The dimensionality type

h: tuple

The histogram of the number of components of each dimensionality. For example, (8, 0, 3, 0) means eight 0D and three 2D components.

components: array

The component ID of each atom.

cdim: dict

The component dimensionalities

ase.geometry.dimensionality.isolate_components(atoms, kcutoff=None)[source]

Isolates components by dimensionality type.

Given a k-value cutoff the components (connected clusters) are identified. For each component an Atoms object is created, which contains that component only. The geometry of the resulting Atoms object depends on the component dimensionality type:

0D: The cell is a tight box around the atoms. pbc=[0, 0, 0].

The cell has no physical meaning.

1D: The chain is aligned along the z-axis. pbc=[0, 0, 1].

The x and y cell directions have no physical meaning.

2D: The layer is aligned in the x-y plane. pbc=[1, 1, 0].

The z cell direction has no physical meaning.

3D: The original cell is used. pbc=[1, 1, 1].

Parameters:

atoms: ASE atoms object

The system to analyze.

kcutoff: float

The k-value cutoff to use. Default=None, in which case the dimensionality scoring parameter is used to select the cutoff.

Returns:

components: dict

key: the component dimenionalities. values: a list of Atoms objects for each dimensionality type.