From a7a7ac268659f6e3b5d85b251feb780843a6bbab Mon Sep 17 00:00:00 2001
From: VsevolodX <79542055+VsevolodX@users.noreply.github.com>
Date: Tue, 17 Dec 2024 20:20:41 -0800
Subject: [PATCH 1/6] update: add slab tutorial nb
---
.../create_slab_SrTiO3.ipynb | 501 ++++++++++++++++++
1 file changed, 501 insertions(+)
create mode 100644 other/materials_designer/specific_examples/create_slab_SrTiO3.ipynb
diff --git a/other/materials_designer/specific_examples/create_slab_SrTiO3.ipynb b/other/materials_designer/specific_examples/create_slab_SrTiO3.ipynb
new file mode 100644
index 00000000..20266d65
--- /dev/null
+++ b/other/materials_designer/specific_examples/create_slab_SrTiO3.ipynb
@@ -0,0 +1,501 @@
+{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "source": [
+ "# Create a slab with specified termination\n",
+ "\n",
+ "Create a slab with a specified termination from a bulk material. \n",
+ "\n",
+ "
Usage
\n",
+ "\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. if prompted, select the termination for the slab in cell 2.5.\n",
+ "1. Scroll down to view results. \n",
+ "\n",
+ "\n",
+ "## Notes\n",
+ "\n",
+ "1. For more information, see [Introduction](Introduction.ipynb)\n",
+ "\n"
+ ],
+ "metadata": {
+ "collapsed": false
+ },
+ "id": "95a274d80df28ccd"
+ },
+ {
+ "cell_type": "markdown",
+ "source": [
+ "## 1. Prepare the Environment\n",
+ "### 1.1. Set up defect parameters "
+ ],
+ "metadata": {
+ "collapsed": false
+ },
+ "id": "d55eaee8bc55bffd"
+ },
+ {
+ "cell_type": "code",
+ "outputs": [],
+ "source": [
+ "# Enable interactive selection of terminations via UI prompt\n",
+ "IS_TERMINATIONS_SELECTION_INTERACTIVE = False \n",
+ "\n",
+ "MILLER_INDICES = (0, 1, 1)\n",
+ "THICKNESS = 3 # in atomic layers\n",
+ "VACUUM = 10.0 # in angstroms\n",
+ "XY_SUPERCELL_MATRIX = [[1, 0], [0, 1]]\n",
+ "USE_ORTHOGONAL_Z = True\n",
+ "USE_CONVENTIONAL_CELL = True\n",
+ "\n",
+ "# Index of the termination to be selected\n",
+ "TERMINATION_INDEX = 0"
+ ],
+ "metadata": {
+ "collapsed": false,
+ "ExecuteTime": {
+ "end_time": "2024-12-16T00:26:01.096831Z",
+ "start_time": "2024-12-16T00:26:01.093579Z"
+ }
+ },
+ "id": "4b64735060047bec",
+ "execution_count": 27
+ },
+ {
+ "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": "5e0ce05f6f031b3f"
+ },
+ {
+ "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",
+ " await install_packages(\"\")"
+ ],
+ "metadata": {
+ "collapsed": false,
+ "ExecuteTime": {
+ "end_time": "2024-12-16T00:26:01.135358Z",
+ "start_time": "2024-12-16T00:26:01.132445Z"
+ }
+ },
+ "id": "b457673560550933",
+ "execution_count": 28
+ },
+ {
+ "cell_type": "markdown",
+ "source": [
+ "### 1.3. Get input materials"
+ ],
+ "metadata": {
+ "collapsed": false
+ },
+ "id": "1659a8e9afe434fb"
+ },
+ {
+ "cell_type": "code",
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "0: 0-Ni\n",
+ "1: 1-Graphene\n",
+ "2: 10-Al2O3, Sapphire, RHL (R-3c) 3D (Bulk), mp-1143 (1)\n",
+ "3: 11-ZnO, Zinc Oxide, HEX (P6_3mc) 3D (Bulk), mp-2133\n",
+ "4: 12-Cd4 Te4\n",
+ "5: 13-Si4 C4\n",
+ "6: 14-GaN, Gallium Nitride, HEX (P6_3mc) 3D (Bulk), mp-804\n",
+ "7: 15-WS2, Tungsten Disulfide, HEX (P-6m2) 2D (Monolayer), 2dm-3749\n",
+ "8: 16 - In4 P4\n",
+ "9: 17 Graphene (Zigzag nanoribbon)\n",
+ "10: 4-Te2Mo\n",
+ "11: 5-HfO2\n",
+ "12: 6-Ni4(110), termination Ni_Pmmm_2, Slab, Terrace, 1 steps, [2 0 0]\n",
+ "13: 7-Ag4\n",
+ "14: 8-Si, Silicene, HEX (P-3m1) 2D (Monolayer), 2dm-5934\n",
+ "15: 9-GaAs, Gallium Arsenide, FCC (F-43m) 3D (Bulk), mp-2534\n",
+ "16: 99 test material\n",
+ "17: C, Graphene, HEX (P6:mmm) 2D (Monolayer), 2dm-3993 (Zigzag nanoribbon)\n",
+ "18: Cu4(111)-Cu4(001), Grain Boundary\n",
+ "19: Custom Shape - Etching Pattern\n",
+ "20: Custom Shape - Transistor\n",
+ "21: Graphene (Zigzag nanoribbon)\n",
+ "22: Ni, Nickel, FCC (Fm-3m) 3D (Bulk), mp-23 passivated\n",
+ "23: Ni25 C1, Substitution C Defect, Pair Defect, Vacancy and Substitution Defect Pair\n",
+ "24: Ni4(001), termination Ni_P4:mmm_2, Slab with box cutout\n",
+ "25: O3SrTi(001), termination SrO_P4:mmm_2, Slab\n",
+ "26: O3SrTi(011), termination SrTiO_Pmmm_3, Slab\n",
+ "27: S4W2(001), termination S_P6:mmm_1, Slab\n",
+ "28: Si, Silicene, HEX (P-3m1) 2D (Monolayer), 2dm-5934\n",
+ "29: Si8(110), termination Si_Pmma_4, Slab\n",
+ "30: Silicon Nanowire\n",
+ "31: Sr1 Ti1 O3\n",
+ "32: test material2024-12-11 12:42:53\n",
+ "Retrieved 33 materials.\n"
+ ]
+ }
+ ],
+ "source": [
+ "from utils.jupyterlite import get_materials\n",
+ "from mat3ra.made.tools.modify import rotate\n",
+ "\n",
+ "materials = get_materials(globals())\n",
+ "material = materials[31]\n",
+ "original_material = material\n",
+ "material = rotate(material, axis=[1,0,0], angle=10, rotate_cell=False)"
+ ],
+ "metadata": {
+ "collapsed": false,
+ "ExecuteTime": {
+ "end_time": "2024-12-16T00:31:15.304138Z",
+ "start_time": "2024-12-16T00:31:15.176360Z"
+ }
+ },
+ "id": "b588ccfe51967a86",
+ "execution_count": 57
+ },
+ {
+ "cell_type": "markdown",
+ "source": [
+ "### 1.4. Preview the material"
+ ],
+ "metadata": {
+ "collapsed": false
+ },
+ "id": "8c13970a869adfa9"
+ },
+ {
+ "cell_type": "code",
+ "outputs": [
+ {
+ "data": {
+ "text/plain": "GridBox(children=(VBox(children=(Label(value='O3SrTi - Material - rotation: 0x', layout=Layout(align_self='cen…",
+ "application/vnd.jupyter.widget-view+json": {
+ "version_major": 2,
+ "version_minor": 0,
+ "model_id": "fd7bef2935be4779ad72fe347098f872"
+ }
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/plain": "GridBox(children=(VBox(children=(Label(value='O3SrTi - Material - rotation: -90x', layout=Layout(align_self='c…",
+ "application/vnd.jupyter.widget-view+json": {
+ "version_major": 2,
+ "version_minor": 0,
+ "model_id": "302d7096e74047e29eea949b10439117"
+ }
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
+ "source": [
+ "from utils.visualize import visualize_materials as visualize\n",
+ "\n",
+ "visualize([original_material, material], repetitions=[3, 3, 1], rotation=\"0x\")\n",
+ "visualize([original_material, material], repetitions=[3, 3, 1], rotation=\"-90x\")"
+ ],
+ "metadata": {
+ "collapsed": false,
+ "ExecuteTime": {
+ "end_time": "2024-12-16T00:31:17.165998Z",
+ "start_time": "2024-12-16T00:31:16.906698Z"
+ }
+ },
+ "id": "c4f6e2697f97965f",
+ "execution_count": 58
+ },
+ {
+ "cell_type": "markdown",
+ "source": [
+ "## 2. Configure slab and select termination\n",
+ "\n",
+ "### 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": "6634dae92a6c07b9"
+ },
+ {
+ "cell_type": "code",
+ "outputs": [],
+ "source": [
+ "\n",
+ "from mat3ra.made.tools.build.slab import SlabConfiguration\n",
+ "\n",
+ "slab_configuration = SlabConfiguration(\n",
+ " bulk=material,\n",
+ " miller_indices=MILLER_INDICES,\n",
+ " thickness=THICKNESS, # in atomic layers\n",
+ " vacuum=VACUUM, # in angstroms\n",
+ " xy_supercell_matrix=XY_SUPERCELL_MATRIX,\n",
+ " use_orthogonal_z=USE_ORTHOGONAL_Z,\n",
+ " use_conventional_cell=USE_CONVENTIONAL_CELL,\n",
+ ")"
+ ],
+ "metadata": {
+ "collapsed": false,
+ "ExecuteTime": {
+ "end_time": "2024-12-16T00:32:05.193281Z",
+ "start_time": "2024-12-16T00:32:05.185068Z"
+ }
+ },
+ "id": "3ad6765249610aa4",
+ "execution_count": 59
+ },
+ {
+ "cell_type": "markdown",
+ "source": [
+ "### 2.2. Get possible terminations for the slabs"
+ ],
+ "metadata": {
+ "collapsed": false
+ },
+ "id": "afb4c9bb89c8690b"
+ },
+ {
+ "cell_type": "code",
+ "outputs": [],
+ "source": [
+ "from mat3ra.made.tools.build.slab import get_terminations\n",
+ "slab_terminations = get_terminations(slab_configuration)"
+ ],
+ "metadata": {
+ "collapsed": false,
+ "ExecuteTime": {
+ "end_time": "2024-12-16T00:32:06.925441Z",
+ "start_time": "2024-12-16T00:32:06.863905Z"
+ }
+ },
+ "id": "70bec9d69d58b28a",
+ "execution_count": 60
+ },
+ {
+ "cell_type": "markdown",
+ "source": [
+ "### 2.3. Visualize slabs for all possible terminations"
+ ],
+ "metadata": {
+ "collapsed": false
+ },
+ "id": "c6e2e18452972b21"
+ },
+ {
+ "cell_type": "code",
+ "outputs": [
+ {
+ "data": {
+ "text/plain": "GridBox(children=(VBox(children=(Label(value='O9Sr3Ti3 - TiO_Pmmm_2 - rotation: -90x', layout=Layout(align_sel…",
+ "application/vnd.jupyter.widget-view+json": {
+ "version_major": 2,
+ "version_minor": 0,
+ "model_id": "1324c100d020440db529c89600d42823"
+ }
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
+ "source": [
+ "from mat3ra.made.tools.build.slab import create_slab\n",
+ "\n",
+ "slabs = [create_slab(slab_configuration, termination) for termination in slab_terminations]\n",
+ "\n",
+ "visualize([{\"material\":slab, \"title\": slab.metadata[\"build\"][\"termination\"]} for slab in slabs ], repetitions=[3, 3, 1], rotation=\"-90x\")"
+ ],
+ "metadata": {
+ "collapsed": false,
+ "ExecuteTime": {
+ "end_time": "2024-12-16T00:32:09.015748Z",
+ "start_time": "2024-12-16T00:32:08.474098Z"
+ }
+ },
+ "id": "246cb1f0437dbde0",
+ "execution_count": 61
+ },
+ {
+ "cell_type": "markdown",
+ "source": [
+ "\n",
+ "### 2.4. Print terminations for the Slab"
+ ],
+ "metadata": {
+ "collapsed": false
+ },
+ "id": "c06cd779e3b76a5f"
+ },
+ {
+ "cell_type": "code",
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Terminations\n",
+ " 0: TiO_Pmmm_2\n",
+ " 1: O2_Pmmm_2\n",
+ " 2: Sr_Pmmm_1\n"
+ ]
+ }
+ ],
+ "source": [
+ "print(\"Terminations\")\n",
+ "for idx, termination in enumerate(slab_terminations):\n",
+ " print(f\" {idx}: {termination}\")"
+ ],
+ "metadata": {
+ "collapsed": false,
+ "ExecuteTime": {
+ "end_time": "2024-12-16T00:32:15.091177Z",
+ "start_time": "2024-12-16T00:32:15.087712Z"
+ }
+ },
+ "id": "92bdfc42a0d8e0c",
+ "execution_count": 62
+ },
+ {
+ "cell_type": "markdown",
+ "source": [
+ "### 2.5. Select termination for the Slab"
+ ],
+ "metadata": {
+ "collapsed": false
+ },
+ "id": "51e59fdb80b92b2d"
+ },
+ {
+ "cell_type": "code",
+ "outputs": [],
+ "source": [
+ "from utils.io import ui_prompt_select_array_element_by_index, ui_prompt_select_array_element_by_index_pyodide\n",
+ "\n",
+ "termination_index = TERMINATION_INDEX\n",
+ "\n",
+ "termination = slab_terminations[termination_index]\n",
+ "if IS_TERMINATIONS_SELECTION_INTERACTIVE:\n",
+ " if sys.platform == \"emscripten\":\n",
+ " termination = await ui_prompt_select_array_element_by_index_pyodide(slab_terminations, element_name=\"termination\")\n",
+ " else:\n",
+ " termination = ui_prompt_select_array_element_by_index(slab_terminations, element_name=\"termination\")"
+ ],
+ "metadata": {
+ "collapsed": false
+ },
+ "id": "905e116e59b3e16e",
+ "execution_count": null
+ },
+ {
+ "cell_type": "markdown",
+ "source": [
+ "## 3. Create the slab with selected termination"
+ ],
+ "metadata": {
+ "collapsed": false
+ },
+ "id": "143bc82b430b37d5"
+ },
+ {
+ "cell_type": "code",
+ "outputs": [],
+ "source": [
+ "from mat3ra.made.tools.build.slab import create_slab\n",
+ "\n",
+ "slab = create_slab(slab_configuration, termination)"
+ ],
+ "metadata": {
+ "collapsed": false
+ },
+ "id": "aeeac03a236fe058",
+ "execution_count": null
+ },
+ {
+ "cell_type": "markdown",
+ "source": [
+ "## 4. Visualize the slab"
+ ],
+ "metadata": {
+ "collapsed": false
+ },
+ "id": "301dd99ed1425f62"
+ },
+ {
+ "cell_type": "code",
+ "outputs": [],
+ "source": [
+ "visualize(slab, repetitions=[1, 1, 1], rotation=\"0x\")"
+ ],
+ "metadata": {
+ "collapsed": false
+ },
+ "id": "19b8867953bc3f1b",
+ "execution_count": null
+ },
+ {
+ "cell_type": "markdown",
+ "source": [
+ "# 5. Pass material to the outside runtime"
+ ],
+ "metadata": {
+ "collapsed": false
+ },
+ "id": "d667623ad5f2e061"
+ },
+ {
+ "cell_type": "code",
+ "outputs": [],
+ "source": [
+ "from utils.jupyterlite import set_materials\n",
+ "set_materials(slab)"
+ ],
+ "metadata": {
+ "collapsed": false
+ },
+ "id": "3705115f04ac0010",
+ "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
+}
From 96e84dc03203d83084a188428eaa039f3918a8b8 Mon Sep 17 00:00:00 2001
From: VsevolodX <79542055+VsevolodX@users.noreply.github.com>
Date: Tue, 17 Dec 2024 21:02:07 -0800
Subject: [PATCH 2/6] feat: add slab tutorial
---
...O3.ipynb => slab_strontium_titanate.ipynb} | 185 +++---------------
1 file changed, 30 insertions(+), 155 deletions(-)
rename other/materials_designer/specific_examples/{create_slab_SrTiO3.ipynb => slab_strontium_titanate.ipynb} (59%)
diff --git a/other/materials_designer/specific_examples/create_slab_SrTiO3.ipynb b/other/materials_designer/specific_examples/slab_strontium_titanate.ipynb
similarity index 59%
rename from other/materials_designer/specific_examples/create_slab_SrTiO3.ipynb
rename to other/materials_designer/specific_examples/slab_strontium_titanate.ipynb
index 20266d65..e569e12d 100644
--- a/other/materials_designer/specific_examples/create_slab_SrTiO3.ipynb
+++ b/other/materials_designer/specific_examples/slab_strontium_titanate.ipynb
@@ -3,24 +3,21 @@
{
"cell_type": "markdown",
"source": [
- "# Create a slab with specified termination\n",
+ "# Slabs of SrTiO3(011) with specified terminations\n",
"\n",
- "Create a slab with a specified termination from a bulk material. \n",
+ "## 0. Introduction\n",
"\n",
- "Usage
\n",
+ "This notebook demonstrates how to create slabs of SrTiO3(011) with specified terminations following the manuscript:\n",
"\n",
+ "> **R. I. Eglitis and David Vanderbilt**\n",
+ "> *First-principles calculations of atomic and electronic structure of SrTiO3 (001) and (011) surfaces*\n",
+ "> Phys. Rev. B 77, 195408 (2008)\n",
+ "> [DOI: 10.1103/PhysRevB.77.195408](https://doi.org/10.1103/PhysRevB.77.195408)\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. if prompted, select the termination for the slab in cell 2.5.\n",
- "1. Scroll down to view results. \n",
+ "Replicating the material from the FIG. 2. with 2 different terminations:\n",
"\n",
- "\n",
- "## Notes\n",
- "\n",
- "1. For more information, see [Introduction](Introduction.ipynb)\n",
- "\n"
+ " \n",
+ "\n"
],
"metadata": {
"collapsed": false
@@ -56,14 +53,10 @@
"TERMINATION_INDEX = 0"
],
"metadata": {
- "collapsed": false,
- "ExecuteTime": {
- "end_time": "2024-12-16T00:26:01.096831Z",
- "start_time": "2024-12-16T00:26:01.093579Z"
- }
+ "collapsed": false
},
"id": "4b64735060047bec",
- "execution_count": 27
+ "execution_count": null
},
{
"cell_type": "markdown",
@@ -90,14 +83,10 @@
" await install_packages(\"\")"
],
"metadata": {
- "collapsed": false,
- "ExecuteTime": {
- "end_time": "2024-12-16T00:26:01.135358Z",
- "start_time": "2024-12-16T00:26:01.132445Z"
- }
+ "collapsed": false
},
"id": "b457673560550933",
- "execution_count": 28
+ "execution_count": null
},
{
"cell_type": "markdown",
@@ -111,48 +100,7 @@
},
{
"cell_type": "code",
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "0: 0-Ni\n",
- "1: 1-Graphene\n",
- "2: 10-Al2O3, Sapphire, RHL (R-3c) 3D (Bulk), mp-1143 (1)\n",
- "3: 11-ZnO, Zinc Oxide, HEX (P6_3mc) 3D (Bulk), mp-2133\n",
- "4: 12-Cd4 Te4\n",
- "5: 13-Si4 C4\n",
- "6: 14-GaN, Gallium Nitride, HEX (P6_3mc) 3D (Bulk), mp-804\n",
- "7: 15-WS2, Tungsten Disulfide, HEX (P-6m2) 2D (Monolayer), 2dm-3749\n",
- "8: 16 - In4 P4\n",
- "9: 17 Graphene (Zigzag nanoribbon)\n",
- "10: 4-Te2Mo\n",
- "11: 5-HfO2\n",
- "12: 6-Ni4(110), termination Ni_Pmmm_2, Slab, Terrace, 1 steps, [2 0 0]\n",
- "13: 7-Ag4\n",
- "14: 8-Si, Silicene, HEX (P-3m1) 2D (Monolayer), 2dm-5934\n",
- "15: 9-GaAs, Gallium Arsenide, FCC (F-43m) 3D (Bulk), mp-2534\n",
- "16: 99 test material\n",
- "17: C, Graphene, HEX (P6:mmm) 2D (Monolayer), 2dm-3993 (Zigzag nanoribbon)\n",
- "18: Cu4(111)-Cu4(001), Grain Boundary\n",
- "19: Custom Shape - Etching Pattern\n",
- "20: Custom Shape - Transistor\n",
- "21: Graphene (Zigzag nanoribbon)\n",
- "22: Ni, Nickel, FCC (Fm-3m) 3D (Bulk), mp-23 passivated\n",
- "23: Ni25 C1, Substitution C Defect, Pair Defect, Vacancy and Substitution Defect Pair\n",
- "24: Ni4(001), termination Ni_P4:mmm_2, Slab with box cutout\n",
- "25: O3SrTi(001), termination SrO_P4:mmm_2, Slab\n",
- "26: O3SrTi(011), termination SrTiO_Pmmm_3, Slab\n",
- "27: S4W2(001), termination S_P6:mmm_1, Slab\n",
- "28: Si, Silicene, HEX (P-3m1) 2D (Monolayer), 2dm-5934\n",
- "29: Si8(110), termination Si_Pmma_4, Slab\n",
- "30: Silicon Nanowire\n",
- "31: Sr1 Ti1 O3\n",
- "32: test material2024-12-11 12:42:53\n",
- "Retrieved 33 materials.\n"
- ]
- }
- ],
+ "outputs": [],
"source": [
"from utils.jupyterlite import get_materials\n",
"from mat3ra.made.tools.modify import rotate\n",
@@ -163,14 +111,10 @@
"material = rotate(material, axis=[1,0,0], angle=10, rotate_cell=False)"
],
"metadata": {
- "collapsed": false,
- "ExecuteTime": {
- "end_time": "2024-12-16T00:31:15.304138Z",
- "start_time": "2024-12-16T00:31:15.176360Z"
- }
+ "collapsed": false
},
"id": "b588ccfe51967a86",
- "execution_count": 57
+ "execution_count": null
},
{
"cell_type": "markdown",
@@ -184,32 +128,7 @@
},
{
"cell_type": "code",
- "outputs": [
- {
- "data": {
- "text/plain": "GridBox(children=(VBox(children=(Label(value='O3SrTi - Material - rotation: 0x', layout=Layout(align_self='cen…",
- "application/vnd.jupyter.widget-view+json": {
- "version_major": 2,
- "version_minor": 0,
- "model_id": "fd7bef2935be4779ad72fe347098f872"
- }
- },
- "metadata": {},
- "output_type": "display_data"
- },
- {
- "data": {
- "text/plain": "GridBox(children=(VBox(children=(Label(value='O3SrTi - Material - rotation: -90x', layout=Layout(align_self='c…",
- "application/vnd.jupyter.widget-view+json": {
- "version_major": 2,
- "version_minor": 0,
- "model_id": "302d7096e74047e29eea949b10439117"
- }
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
+ "outputs": [],
"source": [
"from utils.visualize import visualize_materials as visualize\n",
"\n",
@@ -217,14 +136,10 @@
"visualize([original_material, material], repetitions=[3, 3, 1], rotation=\"-90x\")"
],
"metadata": {
- "collapsed": false,
- "ExecuteTime": {
- "end_time": "2024-12-16T00:31:17.165998Z",
- "start_time": "2024-12-16T00:31:16.906698Z"
- }
+ "collapsed": false
},
"id": "c4f6e2697f97965f",
- "execution_count": 58
+ "execution_count": null
},
{
"cell_type": "markdown",
@@ -257,14 +172,10 @@
")"
],
"metadata": {
- "collapsed": false,
- "ExecuteTime": {
- "end_time": "2024-12-16T00:32:05.193281Z",
- "start_time": "2024-12-16T00:32:05.185068Z"
- }
+ "collapsed": false
},
"id": "3ad6765249610aa4",
- "execution_count": 59
+ "execution_count": null
},
{
"cell_type": "markdown",
@@ -284,14 +195,10 @@
"slab_terminations = get_terminations(slab_configuration)"
],
"metadata": {
- "collapsed": false,
- "ExecuteTime": {
- "end_time": "2024-12-16T00:32:06.925441Z",
- "start_time": "2024-12-16T00:32:06.863905Z"
- }
+ "collapsed": false
},
"id": "70bec9d69d58b28a",
- "execution_count": 60
+ "execution_count": null
},
{
"cell_type": "markdown",
@@ -305,20 +212,7 @@
},
{
"cell_type": "code",
- "outputs": [
- {
- "data": {
- "text/plain": "GridBox(children=(VBox(children=(Label(value='O9Sr3Ti3 - TiO_Pmmm_2 - rotation: -90x', layout=Layout(align_sel…",
- "application/vnd.jupyter.widget-view+json": {
- "version_major": 2,
- "version_minor": 0,
- "model_id": "1324c100d020440db529c89600d42823"
- }
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
+ "outputs": [],
"source": [
"from mat3ra.made.tools.build.slab import create_slab\n",
"\n",
@@ -327,14 +221,10 @@
"visualize([{\"material\":slab, \"title\": slab.metadata[\"build\"][\"termination\"]} for slab in slabs ], repetitions=[3, 3, 1], rotation=\"-90x\")"
],
"metadata": {
- "collapsed": false,
- "ExecuteTime": {
- "end_time": "2024-12-16T00:32:09.015748Z",
- "start_time": "2024-12-16T00:32:08.474098Z"
- }
+ "collapsed": false
},
"id": "246cb1f0437dbde0",
- "execution_count": 61
+ "execution_count": null
},
{
"cell_type": "markdown",
@@ -349,32 +239,17 @@
},
{
"cell_type": "code",
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "Terminations\n",
- " 0: TiO_Pmmm_2\n",
- " 1: O2_Pmmm_2\n",
- " 2: Sr_Pmmm_1\n"
- ]
- }
- ],
+ "outputs": [],
"source": [
"print(\"Terminations\")\n",
"for idx, termination in enumerate(slab_terminations):\n",
" print(f\" {idx}: {termination}\")"
],
"metadata": {
- "collapsed": false,
- "ExecuteTime": {
- "end_time": "2024-12-16T00:32:15.091177Z",
- "start_time": "2024-12-16T00:32:15.087712Z"
- }
+ "collapsed": false
},
"id": "92bdfc42a0d8e0c",
- "execution_count": 62
+ "execution_count": null
},
{
"cell_type": "markdown",
From b3961e2e11b8e2f508e920903752fa0a07208425 Mon Sep 17 00:00:00 2001
From: VsevolodX <79542055+VsevolodX@users.noreply.github.com>
Date: Tue, 17 Dec 2024 21:23:35 -0800
Subject: [PATCH 3/6] update: use standata
---
.../slab_strontium_titanate.ipynb | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/other/materials_designer/specific_examples/slab_strontium_titanate.ipynb b/other/materials_designer/specific_examples/slab_strontium_titanate.ipynb
index e569e12d..edd00911 100644
--- a/other/materials_designer/specific_examples/slab_strontium_titanate.ipynb
+++ b/other/materials_designer/specific_examples/slab_strontium_titanate.ipynb
@@ -102,13 +102,13 @@
"cell_type": "code",
"outputs": [],
"source": [
- "from utils.jupyterlite import get_materials\n",
+ "from mat3ra.made.material import Material\n",
+ "from mat3ra.standata.materials import Materials\n",
"from mat3ra.made.tools.modify import rotate\n",
"\n",
- "materials = get_materials(globals())\n",
- "material = materials[31]\n",
- "original_material = material\n",
- "material = rotate(material, axis=[1,0,0], angle=10, rotate_cell=False)"
+ "material = Material(Materials.get_by_name_first_match(\"SrTiO3\"))\n",
+ "# Rotate material to break symmetry to allow for different terminations detection\n",
+ "adjusted_material = rotate(material, axis=[1,0,0], angle=10, rotate_cell=False)"
],
"metadata": {
"collapsed": false
@@ -132,8 +132,8 @@
"source": [
"from utils.visualize import visualize_materials as visualize\n",
"\n",
- "visualize([original_material, material], repetitions=[3, 3, 1], rotation=\"0x\")\n",
- "visualize([original_material, material], repetitions=[3, 3, 1], rotation=\"-90x\")"
+ "visualize(adjusted_material, repetitions=[3, 3, 1], rotation=\"0x\")\n",
+ "visualize(adjusted_material, repetitions=[3, 3, 1], rotation=\"-90x\")"
],
"metadata": {
"collapsed": false
From 7046db081ed987da13a93a6a243bb02d7b9d470d Mon Sep 17 00:00:00 2001
From: VsevolodX <79542055+VsevolodX@users.noreply.github.com>
Date: Wed, 18 Dec 2024 13:57:43 -0800
Subject: [PATCH 4/6] chore: cleanup
---
.../specific_examples/slab_strontium_titanate.ipynb | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/other/materials_designer/specific_examples/slab_strontium_titanate.ipynb b/other/materials_designer/specific_examples/slab_strontium_titanate.ipynb
index edd00911..95fd3fd2 100644
--- a/other/materials_designer/specific_examples/slab_strontium_titanate.ipynb
+++ b/other/materials_designer/specific_examples/slab_strontium_titanate.ipynb
@@ -108,7 +108,7 @@
"\n",
"material = Material(Materials.get_by_name_first_match(\"SrTiO3\"))\n",
"# Rotate material to break symmetry to allow for different terminations detection\n",
- "adjusted_material = rotate(material, axis=[1,0,0], angle=10, rotate_cell=False)"
+ "material = rotate(material, axis=[1,0,0], angle=5)"
],
"metadata": {
"collapsed": false
@@ -132,8 +132,8 @@
"source": [
"from utils.visualize import visualize_materials as visualize\n",
"\n",
- "visualize(adjusted_material, repetitions=[3, 3, 1], rotation=\"0x\")\n",
- "visualize(adjusted_material, repetitions=[3, 3, 1], rotation=\"-90x\")"
+ "visualize(material, repetitions=[3, 3, 3], rotation=\"0x\")\n",
+ "visualize(material, repetitions=[3, 3, 3], rotation=\"-90x\")"
],
"metadata": {
"collapsed": false
From 81f10c79007b699b8bf456cf65bcecadacd1727d Mon Sep 17 00:00:00 2001
From: VsevolodX <79542055+VsevolodX@users.noreply.github.com>
Date: Wed, 18 Dec 2024 15:55:48 -0800
Subject: [PATCH 5/6] chore: cleanup
---
.../slab_strontium_titanate.ipynb | 129 ++----------------
1 file changed, 13 insertions(+), 116 deletions(-)
diff --git a/other/materials_designer/specific_examples/slab_strontium_titanate.ipynb b/other/materials_designer/specific_examples/slab_strontium_titanate.ipynb
index 95fd3fd2..53ea6452 100644
--- a/other/materials_designer/specific_examples/slab_strontium_titanate.ipynb
+++ b/other/materials_designer/specific_examples/slab_strontium_titanate.ipynb
@@ -39,18 +39,12 @@
"cell_type": "code",
"outputs": [],
"source": [
- "# Enable interactive selection of terminations via UI prompt\n",
- "IS_TERMINATIONS_SELECTION_INTERACTIVE = False \n",
- "\n",
"MILLER_INDICES = (0, 1, 1)\n",
"THICKNESS = 3 # in atomic layers\n",
"VACUUM = 10.0 # in angstroms\n",
"XY_SUPERCELL_MATRIX = [[1, 0], [0, 1]]\n",
"USE_ORTHOGONAL_Z = True\n",
- "USE_CONVENTIONAL_CELL = True\n",
- "\n",
- "# Index of the termination to be selected\n",
- "TERMINATION_INDEX = 0"
+ "USE_CONVENTIONAL_CELL = True\n"
],
"metadata": {
"collapsed": false
@@ -108,7 +102,7 @@
"\n",
"material = Material(Materials.get_by_name_first_match(\"SrTiO3\"))\n",
"# Rotate material to break symmetry to allow for different terminations detection\n",
- "material = rotate(material, axis=[1,0,0], angle=5)"
+ "material = rotate(material, axis=[1,0,0], angle=10)"
],
"metadata": {
"collapsed": false
@@ -144,7 +138,7 @@
{
"cell_type": "markdown",
"source": [
- "## 2. Configure slab and select termination\n",
+ "## 2. Configure slab\n",
"\n",
"### 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"
@@ -192,7 +186,10 @@
"outputs": [],
"source": [
"from mat3ra.made.tools.build.slab import get_terminations\n",
- "slab_terminations = get_terminations(slab_configuration)"
+ "slab_terminations = get_terminations(slab_configuration)\n",
+ "print(\"Terminations\")\n",
+ "for idx, termination in enumerate(slab_terminations):\n",
+ " print(f\" {idx}: {termination}\")"
],
"metadata": {
"collapsed": false
@@ -203,7 +200,7 @@
{
"cell_type": "markdown",
"source": [
- "### 2.3. Visualize slabs for all possible terminations"
+ "## 3. Visualize slabs for all possible terminations"
],
"metadata": {
"collapsed": false
@@ -218,6 +215,7 @@
"\n",
"slabs = [create_slab(slab_configuration, termination) for termination in slab_terminations]\n",
"\n",
+ "visualize([{\"material\":slab, \"title\": slab.metadata[\"build\"][\"termination\"]} for slab in slabs ], repetitions=[3, 3, 1])\n",
"visualize([{\"material\":slab, \"title\": slab.metadata[\"build\"][\"termination\"]} for slab in slabs ], repetitions=[3, 3, 1], rotation=\"-90x\")"
],
"metadata": {
@@ -229,109 +227,7 @@
{
"cell_type": "markdown",
"source": [
- "\n",
- "### 2.4. Print terminations for the Slab"
- ],
- "metadata": {
- "collapsed": false
- },
- "id": "c06cd779e3b76a5f"
- },
- {
- "cell_type": "code",
- "outputs": [],
- "source": [
- "print(\"Terminations\")\n",
- "for idx, termination in enumerate(slab_terminations):\n",
- " print(f\" {idx}: {termination}\")"
- ],
- "metadata": {
- "collapsed": false
- },
- "id": "92bdfc42a0d8e0c",
- "execution_count": null
- },
- {
- "cell_type": "markdown",
- "source": [
- "### 2.5. Select termination for the Slab"
- ],
- "metadata": {
- "collapsed": false
- },
- "id": "51e59fdb80b92b2d"
- },
- {
- "cell_type": "code",
- "outputs": [],
- "source": [
- "from utils.io import ui_prompt_select_array_element_by_index, ui_prompt_select_array_element_by_index_pyodide\n",
- "\n",
- "termination_index = TERMINATION_INDEX\n",
- "\n",
- "termination = slab_terminations[termination_index]\n",
- "if IS_TERMINATIONS_SELECTION_INTERACTIVE:\n",
- " if sys.platform == \"emscripten\":\n",
- " termination = await ui_prompt_select_array_element_by_index_pyodide(slab_terminations, element_name=\"termination\")\n",
- " else:\n",
- " termination = ui_prompt_select_array_element_by_index(slab_terminations, element_name=\"termination\")"
- ],
- "metadata": {
- "collapsed": false
- },
- "id": "905e116e59b3e16e",
- "execution_count": null
- },
- {
- "cell_type": "markdown",
- "source": [
- "## 3. Create the slab with selected termination"
- ],
- "metadata": {
- "collapsed": false
- },
- "id": "143bc82b430b37d5"
- },
- {
- "cell_type": "code",
- "outputs": [],
- "source": [
- "from mat3ra.made.tools.build.slab import create_slab\n",
- "\n",
- "slab = create_slab(slab_configuration, termination)"
- ],
- "metadata": {
- "collapsed": false
- },
- "id": "aeeac03a236fe058",
- "execution_count": null
- },
- {
- "cell_type": "markdown",
- "source": [
- "## 4. Visualize the slab"
- ],
- "metadata": {
- "collapsed": false
- },
- "id": "301dd99ed1425f62"
- },
- {
- "cell_type": "code",
- "outputs": [],
- "source": [
- "visualize(slab, repetitions=[1, 1, 1], rotation=\"0x\")"
- ],
- "metadata": {
- "collapsed": false
- },
- "id": "19b8867953bc3f1b",
- "execution_count": null
- },
- {
- "cell_type": "markdown",
- "source": [
- "# 5. Pass material to the outside runtime"
+ "## 4. Download materials"
],
"metadata": {
"collapsed": false
@@ -342,8 +238,9 @@
"cell_type": "code",
"outputs": [],
"source": [
- "from utils.jupyterlite import set_materials\n",
- "set_materials(slab)"
+ "from utils.jupyterlite import download_content_to_file\n",
+ "for slab in slabs:\n",
+ " download_content_to_file(slab, f\"{slab.name}.json\")"
],
"metadata": {
"collapsed": false
From 0d44530b9e1f3524b225dd62f28caeeee20cbf55 Mon Sep 17 00:00:00 2001
From: VsevolodX <79542055+VsevolodX@users.noreply.github.com>
Date: Wed, 18 Dec 2024 18:26:31 -0800
Subject: [PATCH 6/6] chore: adjsut wording
---
.../slab_strontium_titanate.ipynb | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/other/materials_designer/specific_examples/slab_strontium_titanate.ipynb b/other/materials_designer/specific_examples/slab_strontium_titanate.ipynb
index 53ea6452..bc23643a 100644
--- a/other/materials_designer/specific_examples/slab_strontium_titanate.ipynb
+++ b/other/materials_designer/specific_examples/slab_strontium_titanate.ipynb
@@ -71,9 +71,10 @@
"\n",
"if sys.platform == \"emscripten\":\n",
" import micropip\n",
- " \n",
+ "\n",
" await micropip.install('mat3ra-api-examples', deps=False)\n",
" from utils.jupyterlite import install_packages\n",
+ "\n",
" await install_packages(\"\")"
],
"metadata": {
@@ -101,8 +102,9 @@
"from mat3ra.made.tools.modify import rotate\n",
"\n",
"material = Material(Materials.get_by_name_first_match(\"SrTiO3\"))\n",
- "# Rotate material to break symmetry to allow for different terminations detection\n",
- "material = rotate(material, axis=[1,0,0], angle=10)"
+ "# Rotate material to correctly identify multiple terminations.\n",
+ "# Without the rotation, the current implementation only finds a single termination (as of 2024-12).\n",
+ "material = rotate(material, axis=[1, 0, 0], angle=10)"
],
"metadata": {
"collapsed": false
@@ -158,8 +160,8 @@
"slab_configuration = SlabConfiguration(\n",
" bulk=material,\n",
" miller_indices=MILLER_INDICES,\n",
- " thickness=THICKNESS, # in atomic layers\n",
- " vacuum=VACUUM, # in angstroms\n",
+ " thickness=THICKNESS, # in atomic layers\n",
+ " vacuum=VACUUM, # in angstroms\n",
" xy_supercell_matrix=XY_SUPERCELL_MATRIX,\n",
" use_orthogonal_z=USE_ORTHOGONAL_Z,\n",
" use_conventional_cell=USE_CONVENTIONAL_CELL,\n",
@@ -186,6 +188,7 @@
"outputs": [],
"source": [
"from mat3ra.made.tools.build.slab import get_terminations\n",
+ "\n",
"slab_terminations = get_terminations(slab_configuration)\n",
"print(\"Terminations\")\n",
"for idx, termination in enumerate(slab_terminations):\n",
@@ -215,8 +218,9 @@
"\n",
"slabs = [create_slab(slab_configuration, termination) for termination in slab_terminations]\n",
"\n",
- "visualize([{\"material\":slab, \"title\": slab.metadata[\"build\"][\"termination\"]} for slab in slabs ], repetitions=[3, 3, 1])\n",
- "visualize([{\"material\":slab, \"title\": slab.metadata[\"build\"][\"termination\"]} for slab in slabs ], repetitions=[3, 3, 1], rotation=\"-90x\")"
+ "visualize([{\"material\": slab, \"title\": slab.metadata[\"build\"][\"termination\"]} for slab in slabs], repetitions=[3, 3, 1])\n",
+ "visualize([{\"material\": slab, \"title\": slab.metadata[\"build\"][\"termination\"]} for slab in slabs], repetitions=[3, 3, 1],\n",
+ " rotation=\"-90x\")"
],
"metadata": {
"collapsed": false
@@ -239,6 +243,7 @@
"outputs": [],
"source": [
"from utils.jupyterlite import download_content_to_file\n",
+ "\n",
"for slab in slabs:\n",
" download_content_to_file(slab, f\"{slab.name}.json\")"
],