diff --git a/other/materials_designer/Introduction.ipynb b/other/materials_designer/Introduction.ipynb index 37823eb9..ba7d6569 100644 --- a/other/materials_designer/Introduction.ipynb +++ b/other/materials_designer/Introduction.ipynb @@ -18,7 +18,8 @@ "#### [1.1.1. Supercells. Create supercells from 3D crystals.](create_supercell.ipynb)\n", "\n", "### 1.2. 2D Structures.\n", - "#### [1.2.1. Slabs. Create slabs from bulk materials.](create_slab.ipynb)\n", + "#### [1.2.1. Slabs. Create a slab from a bulk material.](create_slab.ipynb)\n", + "#### [1.2.2. Monolayers. Create a monolayer from a bulk material.](create_monolayer.ipynb)\n", "\n", "### 1.3. 1D Structures.\n", "#### [1.3.1. Nanoribbons. Create nanoribbons from 2D materials.](create_nanoribbon.ipynb)\n", @@ -92,6 +93,14 @@ "\n", "#### [7.1.1. More info about the conventions used](under_the_hood.ipynb)." ] + }, + { + "cell_type": "code", + "outputs": [], + "source": [], + "metadata": { + "collapsed": false + } } ], "metadata": { diff --git a/other/materials_designer/create_monolayer.ipynb b/other/materials_designer/create_monolayer.ipynb new file mode 100644 index 00000000..6e2cb957 --- /dev/null +++ b/other/materials_designer/create_monolayer.ipynb @@ -0,0 +1,274 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "source": [ + "# Create a Monolayer\n", + "\n", + "Create a Monolayer of the original structure. \n", + "\n", + "

Usage

\n", + "\n", + "1. Make sure to select Input Materials (in the outer runtime) before running the notebook.\n", + "1. Set notebook parameters in cell 1.1. below (or use the default values).\n", + "1. Click “Run” > “Run All” to run all cells. \n", + "1. Scroll down to view results. " + ], + "metadata": { + "collapsed": false + }, + "id": "a79609c9bc772c5c" + }, + { + "cell_type": "markdown", + "source": [ + "## 1. Prepare the Environment\n", + "### 1.1. Set up transformation parameters " + ], + "metadata": { + "collapsed": false + }, + "id": "47d31d9834478007" + }, + { + "cell_type": "code", + "outputs": [], + "source": [ + "XY_SUPERCELL_MATRIX = [\n", + " [3, 0],\n", + " [0, 3],\n", + "]\n", + "\n", + "VACUUM = 10.0 # Angstrom" + ], + "metadata": { + "collapsed": false + }, + "id": "a2c8922a4e627887", + "execution_count": null + }, + { + "cell_type": "markdown", + "source": [ + "### 1.2. Install Packages\n", + "The step executes only in Pyodide environment. For other environments, the packages should be installed via `pip install` (see [README](../../README.ipynb))." + ], + "metadata": { + "collapsed": false + }, + "id": "6fab076ea1d7a223" + }, + { + "cell_type": "code", + "outputs": [], + "source": [ + "import sys\n", + "\n", + "if sys.platform == \"emscripten\":\n", + " import micropip\n", + "\n", + " await micropip.install('mat3ra-api-examples', deps=False)\n", + " from utils.jupyterlite import install_packages\n", + "\n", + " await install_packages(\"\", \"../../config.yml\")" + ], + "metadata": { + "collapsed": false + }, + "id": "b0c332f1c1f451fd", + "execution_count": null + }, + { + "cell_type": "markdown", + "source": [ + "### 1.3. Get input materials" + ], + "metadata": { + "collapsed": false + }, + "id": "3e9934b458d6cb4" + }, + { + "cell_type": "code", + "outputs": [], + "source": [ + "from utils.jupyterlite import get_materials\n", + "\n", + "materials = get_materials(globals())\n", + "material = materials[0]" + ], + "metadata": { + "collapsed": false + }, + "id": "74cd0d5a3881ab47", + "execution_count": null + }, + { + "cell_type": "markdown", + "source": [ + "### 1.4. Preview the material" + ], + "metadata": { + "collapsed": false + }, + "id": "d4535caf6debb8d4" + }, + { + "cell_type": "code", + "outputs": [], + "source": [ + "from utils.visualize import visualize_materials as visualize\n", + "\n", + "visualize(material, repetitions=[3, 3, 1], rotation=\"0x\")\n", + "visualize(material, repetitions=[3, 3, 1], rotation=\"-90x\")" + ], + "metadata": { + "collapsed": false + }, + "id": "d6bea39864c23ab5", + "execution_count": null + }, + { + "cell_type": "markdown", + "source": [ + "## 2. Create Monolayer" + ], + "metadata": { + "collapsed": false + }, + "id": "5473c36cd254aa89" + }, + { + "cell_type": "markdown", + "source": [ + "### 2.1. Create slab configuration\n", + "Slab Configuration lets define the slab thickness, vacuum, and the Miller indices of the interfacial plane and get the slabs with possible terminations.\n" + ], + "metadata": { + "collapsed": false + }, + "id": "ee17958872d03410" + }, + { + "cell_type": "code", + "outputs": [], + "source": [ + "from mat3ra.made.tools.build.slab import SlabConfiguration\n", + "\n", + "slab_configuration = SlabConfiguration(\n", + " bulk=material,\n", + " miller_indices=(0, 0, 1),\n", + " thickness=1,\n", + " vacuum=VACUUM,\n", + " xy_supercell_matrix=XY_SUPERCELL_MATRIX,\n", + " use_orthogonal_z=True,\n", + " use_conventional_cell=True,\n", + ")" + ], + "metadata": { + "collapsed": false + }, + "id": "b8dc56881543c16c", + "execution_count": null + }, + { + "cell_type": "markdown", + "source": [ + "### 2.2 Create the slab of Single Layer" + ], + "metadata": { + "collapsed": false + }, + "id": "661c76f9bab9f743" + }, + { + "cell_type": "code", + "outputs": [], + "source": [ + "from mat3ra.made.tools.modify import translate_to_z_level, filter_by_box\n", + "from mat3ra.made.tools.build.slab import create_slab\n", + "\n", + "slab = create_slab(slab_configuration)\n", + "\n", + "# Get only the top layer of two -- for AB stacked bilayers forming a 3D bulk basis\n", + "if any(substring in material.name for substring in [\"3D\", \"Bulk\"]):\n", + " centered_slab = translate_to_z_level(slab, z_level=\"center\")\n", + " half_filtered_slab = filter_by_box(centered_slab, [0, 0, 0.5], [1, 1, 1])\n", + " monolayer = translate_to_z_level(half_filtered_slab, z_level=\"center\")" + ], + "metadata": { + "collapsed": false + }, + "id": "cf27e53c85adc447", + "execution_count": null + }, + { + "cell_type": "markdown", + "source": [ + "## 3. Visualize the result" + ], + "metadata": { + "collapsed": false + }, + "id": "527829d64a542d10" + }, + { + "cell_type": "code", + "outputs": [], + "source": [ + "visualize(monolayer, repetitions=[1, 1, 1], rotation=\"0x\")\n", + "visualize(monolayer, repetitions=[1, 1, 1], rotation=\"-90x\")" + ], + "metadata": { + "collapsed": false + }, + "id": "ee12ab13c210b953", + "execution_count": null + }, + { + "cell_type": "markdown", + "source": [ + "# 4. Pass material to the outside runtime" + ], + "metadata": { + "collapsed": false + }, + "id": "6ce5f7dd9a919a08" + }, + { + "cell_type": "code", + "outputs": [], + "source": [ + "from utils.jupyterlite import set_materials\n", + "\n", + "set_materials(monolayer)" + ], + "metadata": { + "collapsed": false + }, + "id": "865c71d008d87beb", + "execution_count": null + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.6" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +}