.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples_generated/dimensionality/dimensionality.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_examples_generated_dimensionality_dimensionality.py: .. _dim_examples: ======================= Dimensionality analysis ======================= This is a example of analysis of the dimensionality of a structure using the :func:`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 :mol:`MoS_2` structure and analyzes its dimensionality. .. GENERATED FROM PYTHON SOURCE LINES 17-36 .. code-block:: Python import ase.build from ase.geometry.dimensionality import analyze_dimensionality from ase.visualize import view 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) # Visualize the structure # view(atoms) .. rst-class:: sphx-glr-script-out .. code-block:: none 1.0 2D (0, 0, 3, 0) 0.9671801741460148 0.9390120940780232 1.8142857142857145 .. GENERATED FROM PYTHON SOURCE LINES 37-43 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 :func:`ase.geometry.dimensionality.isolate_components` function as the example below demonstrates. .. GENERATED FROM PYTHON SOURCE LINES 43-71 .. code-block:: Python import numpy as np import ase.build from ase import Atoms from ase.geometry.dimensionality import isolate_components from ase.visualize import view # 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) # Visualize the structure # view(atoms, block=True) .. rst-class:: sphx-glr-script-out .. code-block:: none counts: [('2D', 2)] 2D 2D .. GENERATED FROM PYTHON SOURCE LINES 72-92 The method is described in the article: | P.M. Larsen, M. Pandey, M. Strange, and K. W. Jacobsen | "Definition of a scoring parameter to identify | low-dimensional materials components" | Phys. Rev. Materials 3 034003, 2019 | :doi:`10.1103/PhysRevMaterials.3.034003` A preprint is available :arxiv:`here <1808.02114>`. .. seealso:: More examples here: `Dimensionality analysis of ICSD and COD databases `_. .. autofunction:: ase.geometry.dimensionality.analyze_dimensionality :noindex: .. autofunction:: ase.geometry.dimensionality.isolate_components :noindex: .. _sphx_glr_download_examples_generated_dimensionality_dimensionality.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: dimensionality.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: dimensionality.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: dimensionality.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_