{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n\n# Dimensionality analysis\n\nThis is a example of analysis of the dimensionality of a structure using\nthe :func:`ase.geometry.dimensionality.analyze_dimensionality` function. This is\nuseful for finding low-dimensional materials, such as 1D chain-like\nstructures, 2D layered structures, or structures with multiple dimensionality\ntypes, such as 1D+3D.\n\nThe example below creates a layered :mol:`MoS_2` structure and analyzes its\ndimensionality.\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import ase.build\nfrom ase.geometry.dimensionality import analyze_dimensionality\nfrom ase.visualize import view\n\natoms = ase.build.mx2(formula='MoS2', kind='2H', a=3.18, thickness=3.19)\natoms.cell[2, 2] = 7.0\natoms.set_pbc((1, 1, 1))\natoms *= 3\n\nintervals = analyze_dimensionality(atoms, method='RDA')\nm = intervals[0]\nprint(sum([e.score for e in intervals]))\nprint(m.dimtype, m.h, m.score, m.a, m.b)\n\natoms.set_tags(m.components)\n# Visualize the structure\n# view(atoms)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Coloring the atoms by their tags shows the distinct bonded clusters, which in\nthis case are separate layers.\n\nEach component in the material can be extracted, or \"*isolated*\",\nusing the :func:`ase.geometry.dimensionality.isolate_components` function as\nthe example below demonstrates.\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import numpy as np\n\nimport ase.build\nfrom ase import Atoms\nfrom ase.geometry.dimensionality import isolate_components\nfrom ase.visualize import view\n\n# build two slabs of different types of MoS2\nrep = [4, 4, 1]\na = ase.build.mx2(formula='MoS2', kind='2H', a=3.18, thickness=3.19) * rep\nb = ase.build.mx2(formula='MoS2', kind='1T', a=3.18, thickness=3.19) * rep\npositions = np.concatenate([a.get_positions(), b.get_positions() + [0, 0, 7]])\nnumbers = np.concatenate([a.numbers, b.numbers])\ncell = a.cell\natoms = Atoms(numbers=numbers, positions=positions, cell=cell, pbc=[1, 1, 1])\natoms.cell[2, 2] = 14.0\n\n# isolate each component in the whole material\nresult = isolate_components(atoms)\nprint('counts:', [(k, len(v)) for k, v in sorted(result.items())])\n\nfor dim, components in result.items():\n for atoms in components:\n print(dim)\n # Visualize the structure\n # view(atoms, block=True)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The method is described in the article:\n\n | P.M. Larsen, M. Pandey, M. Strange, and K. W. Jacobsen\n | \"Definition of a scoring parameter to identify\n | low-dimensional materials components\"\n | Phys. Rev. Materials 3 034003, 2019\n | :doi:`10.1103/PhysRevMaterials.3.034003`\n\nA preprint is available :arxiv:`here <1808.02114>`.\n\n.. seealso::\n\n More examples here: [Dimensionality analysis of ICSD and COD databases](https://cmr.fysik.dtu.dk/lowdim/lowdim.html).\n\n\n.. autofunction:: ase.geometry.dimensionality.analyze_dimensionality\n :noindex:\n.. autofunction:: ase.geometry.dimensionality.isolate_components\n :noindex:\n\n" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.13.7" } }, "nbformat": 4, "nbformat_minor": 0 }