From 8b9ed73e147c898e0943c3401c117b9ca545ff3a Mon Sep 17 00:00:00 2001
From: VsevolodX <79542055+VsevolodX@users.noreply.github.com>
Date: Fri, 22 Nov 2024 17:21:01 -0800
Subject: [PATCH 1/8] feat: add terrace NB
---
other/materials_designer/Introduction.ipynb | 2 +-
.../create_terrace_defect.ipynb | 326 ++++++++++++++++++
2 files changed, 327 insertions(+), 1 deletion(-)
create mode 100644 other/materials_designer/create_terrace_defect.ipynb
diff --git a/other/materials_designer/Introduction.ipynb b/other/materials_designer/Introduction.ipynb
index 8568b4c3..4ce5a626 100644
--- a/other/materials_designer/Introduction.ipynb
+++ b/other/materials_designer/Introduction.ipynb
@@ -59,10 +59,10 @@
"\n",
"### 3.2. Surface Defects\n",
"#### [3.2.1. Adatom Defect on a Slab](create_adatom_defect.ipynb)\n",
+ "#### [3.2.2. Terrace Defect on a Slab](create_terrace_defect.ipynb)\n",
"\n",
"### 3.3. Planar Defects\n",
"#### [3.3.1. Grain Boundary in a 3D Crystal](create_grain_boundary_crystal.ipynb)\n",
- "#### [3.3.2. Grain Boundary in a 2D Material](create_grain_boundary_film.ipynb)\n",
"\n",
"\n",
"## 4. Passivation.\n",
diff --git a/other/materials_designer/create_terrace_defect.ipynb b/other/materials_designer/create_terrace_defect.ipynb
new file mode 100644
index 00000000..111b9fea
--- /dev/null
+++ b/other/materials_designer/create_terrace_defect.ipynb
@@ -0,0 +1,326 @@
+{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "source": [
+ "# Create a Terrace Defect on a Slab\n",
+ "\n",
+ "Create a terrace defect by adding layers to a portion of a slab, defined by a cutting plane and number of additional layers.\n",
+ "\n",
+ "
Usage
\n",
+ "\n",
+ "1. Make sure to select Input Material (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. Wait for the run to complete.\n",
+ "1. Scroll down to view results.\n",
+ "\n",
+ "## Notes\n",
+ "\n",
+ "1. The input material must be a slab (2D periodic structure with vacuum)\n",
+ "2. The terrace is created by adding layers above a cutting plane\n",
+ "3. The cutting plane is defined by its normal direction and a point it passes through\n",
+ "4. The structure can be automatically rotated to match periodic boundary conditions\n"
+ ],
+ "metadata": {
+ "collapsed": false
+ },
+ "id": "f5ca6879c3872454"
+ },
+ {
+ "cell_type": "markdown",
+ "source": [
+ "## 1. Prepare the Environment\n",
+ "### 1.1. Set up the notebook\n",
+ "Set the following flags to control the notebook behavior\n"
+ ],
+ "metadata": {
+ "collapsed": false
+ },
+ "id": "ff0f33c4e6ac1303"
+ },
+ {
+ "cell_type": "code",
+ "outputs": [],
+ "source": [
+ "# Material selection\n",
+ "MATERIAL_INDEX = 0 # Which material to use from input list\n",
+ "\n",
+ "# Terrace parameters\n",
+ "CUT_DIRECTION = [1, 0, 0] # Normal vector describing a plane that cuts the terrace from added layers (Miller indices)\n",
+ "PIVOT_COORDINATE = [0.5, 0.5, 0.5] # Point the cutting plane passes through (fractional)\n",
+ "NUMBER_OF_ADDED_LAYERS = 1 # Height of terrace in atomic layers\n",
+ "USE_CARTESIAN_COORDINATES = False # Use cartesian instead of fractional coordinates\n",
+ "ROTATE_TO_MATCH_PBC = True # Rotate to match periodic boundary conditions\n",
+ "\n",
+ "# Slab parameters for creating a new slab if provided material is not a slab\n",
+ "DEFAULT_SLAB_PARAMETERS = {\n",
+ " \"miller_indices\": (0, 0, 1),\n",
+ " \"thickness\": 6,\n",
+ " \"vacuum\": 10.0,\n",
+ " \"use_orthogonal_z\": True,\n",
+ " \"xy_supercell_matrix\": [[5, 0], [0, 5]]\n",
+ "}\n",
+ "\n",
+ "# Visualization parameters\n",
+ "SHOW_INTERMEDIATE_STEPS = True\n",
+ "VISUALIZE_REPETITIONS = [3, 3, 1] # Structure repeat in view\n"
+ ],
+ "metadata": {
+ "collapsed": false
+ },
+ "id": "dd6ca344ae34a2d6",
+ "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`."
+ ],
+ "metadata": {
+ "collapsed": false
+ },
+ "id": "ac4ec25db74d75f4"
+ },
+ {
+ "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(\"\", \"../../config.yml\")\n"
+ ],
+ "metadata": {
+ "collapsed": false
+ },
+ "id": "38574beae9a769cd",
+ "execution_count": null
+ },
+ {
+ "cell_type": "markdown",
+ "source": [
+ "### 1.3. Load and preview input material"
+ ],
+ "metadata": {
+ "collapsed": false
+ },
+ "id": "c0eab57550f40708"
+ },
+ {
+ "cell_type": "code",
+ "outputs": [],
+ "source": [
+ "from utils.jupyterlite import get_materials\n",
+ "\n",
+ "materials = get_materials(globals())\n"
+ ],
+ "metadata": {
+ "collapsed": false
+ },
+ "id": "f2479655b99cca48",
+ "execution_count": null
+ },
+ {
+ "cell_type": "markdown",
+ "source": [
+ "### 1.4. Create a slab if the input material is not a slab"
+ ],
+ "metadata": {
+ "collapsed": false
+ },
+ "id": "4282a853c29a1501"
+ },
+ {
+ "cell_type": "code",
+ "outputs": [],
+ "source": [
+ "from mat3ra.made.tools.build.slab import create_slab, SlabConfiguration\n",
+ "\n",
+ "slab = materials[0]\n",
+ "if not slab.metadata or slab.metadata[\"build\"][\"configuration\"][\"type\"] != SlabConfiguration.__name__:\n",
+ " print(\"The material is not a slab. Creating a new slab...\")\n",
+ " slab_config = SlabConfiguration(\n",
+ " bulk=materials[0],\n",
+ " miller_indices=DEFAULT_SLAB_PARAMETERS[\"miller_indices\"],\n",
+ " thickness=DEFAULT_SLAB_PARAMETERS[\"thickness\"],\n",
+ " vacuum=DEFAULT_SLAB_PARAMETERS[\"vacuum\"],\n",
+ " use_orthogonal_z=DEFAULT_SLAB_PARAMETERS[\"use_orthogonal_z\"],\n",
+ " xy_supercell_matrix=DEFAULT_SLAB_PARAMETERS[\"xy_supercell_matrix\"]\n",
+ " )\n",
+ "\n",
+ " slab = create_slab(slab_config)"
+ ],
+ "metadata": {
+ "collapsed": false
+ },
+ "id": "80b7b827c2b390c3",
+ "execution_count": null
+ },
+ {
+ "cell_type": "markdown",
+ "source": [
+ "## 2. Prepare Material\n",
+ "### 2.1. Select and visualize initial slab"
+ ],
+ "metadata": {
+ "collapsed": false
+ },
+ "id": "916c8b16e01f86ff"
+ },
+ {
+ "cell_type": "code",
+ "outputs": [],
+ "source": [
+ "from utils.visualize import visualize_materials\n",
+ "\n",
+ "\n",
+ "if SHOW_INTERMEDIATE_STEPS:\n",
+ " print(\"Initial slab structure:\")\n",
+ " visualize_materials(slab, repetitions=VISUALIZE_REPETITIONS)\n",
+ " visualize_materials(slab, repetitions=VISUALIZE_REPETITIONS, rotation=\"-90x\")\n"
+ ],
+ "metadata": {
+ "collapsed": false
+ },
+ "id": "16bb968a93de4b9",
+ "execution_count": null
+ },
+ {
+ "cell_type": "markdown",
+ "source": [
+ "## 3. Generate Terrace Defect\n",
+ "### 3.1. Set up terrace configuration and builder\n"
+ ],
+ "metadata": {
+ "collapsed": false
+ },
+ "id": "9edaa3afb28ee0ad"
+ },
+ {
+ "cell_type": "code",
+ "outputs": [],
+ "source": [
+ "from mat3ra.made.tools.build.defect.builders import TerraceSlabDefectConfiguration, TerraceSlabDefectBuilder\n",
+ "\n",
+ "config = TerraceSlabDefectConfiguration(\n",
+ " crystal=slab,\n",
+ " cut_direction=CUT_DIRECTION,\n",
+ " pivot_coordinate=PIVOT_COORDINATE,\n",
+ " number_of_added_layers=NUMBER_OF_ADDED_LAYERS,\n",
+ " use_cartesian_coordinates=USE_CARTESIAN_COORDINATES,\n",
+ " rotate_to_match_pbc=ROTATE_TO_MATCH_PBC\n",
+ ")\n",
+ "\n",
+ "builder = TerraceSlabDefectBuilder()\n"
+ ],
+ "metadata": {
+ "collapsed": false
+ },
+ "id": "c318fd03c7e667df",
+ "execution_count": null
+ },
+ {
+ "cell_type": "markdown",
+ "source": [
+ "### 3.2. Generate terrace defect\n"
+ ],
+ "metadata": {
+ "collapsed": false
+ },
+ "id": "b9df79c67a870181"
+ },
+ {
+ "cell_type": "code",
+ "outputs": [],
+ "source": [
+ "terrace_slab = builder.get_material(config)\n",
+ "\n",
+ "print(\"\\nTerrace defect created with:\")\n",
+ "print(f\"Cut direction: {CUT_DIRECTION}\")\n",
+ "print(f\"Pivot point: {PIVOT_COORDINATE}\")\n",
+ "print(f\"Added layers: {NUMBER_OF_ADDED_LAYERS}\")\n",
+ "print(f\"Number of atoms: {len(terrace_slab.basis.elements.ids)}\")\n"
+ ],
+ "metadata": {
+ "collapsed": false
+ },
+ "id": "256bc04ff0aa1810",
+ "execution_count": null
+ },
+ {
+ "cell_type": "markdown",
+ "source": [
+ "## 4. Preview the terrace defect"
+ ],
+ "metadata": {
+ "collapsed": false
+ },
+ "id": "9bee7a912a90e33c"
+ },
+ {
+ "cell_type": "code",
+ "outputs": [],
+ "source": [
+ "print(\"Final structure with terrace:\")\n",
+ "visualize_materials(terrace_slab, repetitions=[1, 1, 1])\n",
+ "visualize_materials(terrace_slab, repetitions=[1, 1, 1], rotation=\"-90x\")\n"
+ ],
+ "metadata": {
+ "collapsed": false
+ },
+ "id": "4ffdd8589b02de16",
+ "execution_count": null
+ },
+ {
+ "cell_type": "markdown",
+ "source": [
+ "### 5. Pass data to the outside runtime\n"
+ ],
+ "metadata": {
+ "collapsed": false
+ },
+ "id": "d65865cbab99478"
+ },
+ {
+ "cell_type": "code",
+ "outputs": [],
+ "source": [
+ "from utils.jupyterlite import set_materials\n",
+ "\n",
+ "set_materials(terrace_slab)"
+ ],
+ "metadata": {
+ "collapsed": false
+ },
+ "id": "e292358fe4803b4f",
+ "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 7e21c764218db493bdc7451b83e14a7fc88e8cee Mon Sep 17 00:00:00 2001
From: VsevolodX <79542055+VsevolodX@users.noreply.github.com>
Date: Fri, 22 Nov 2024 17:22:36 -0800
Subject: [PATCH 2/8] chore: format
---
.../create_terrace_defect.ipynb | 20 +++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/other/materials_designer/create_terrace_defect.ipynb b/other/materials_designer/create_terrace_defect.ipynb
index 111b9fea..82495483 100644
--- a/other/materials_designer/create_terrace_defect.ipynb
+++ b/other/materials_designer/create_terrace_defect.ipynb
@@ -64,7 +64,7 @@
"\n",
"# Visualization parameters\n",
"SHOW_INTERMEDIATE_STEPS = True\n",
- "VISUALIZE_REPETITIONS = [3, 3, 1] # Structure repeat in view\n"
+ "CELL_REPETITIONS_FOR_VISUALIZATION = [3, 3, 1] # Structure repeat in view"
],
"metadata": {
"collapsed": false
@@ -94,7 +94,8 @@
"\n",
" await micropip.install('mat3ra-api-examples', deps=False)\n",
" from utils.jupyterlite import install_packages\n",
- " await install_packages(\"\", \"../../config.yml\")\n"
+ "\n",
+ " await install_packages(\"\", \"../../config.yml\")"
],
"metadata": {
"collapsed": false
@@ -118,7 +119,7 @@
"source": [
"from utils.jupyterlite import get_materials\n",
"\n",
- "materials = get_materials(globals())\n"
+ "materials = get_materials(globals())"
],
"metadata": {
"collapsed": false
@@ -179,11 +180,10 @@
"source": [
"from utils.visualize import visualize_materials\n",
"\n",
- "\n",
"if SHOW_INTERMEDIATE_STEPS:\n",
" print(\"Initial slab structure:\")\n",
- " visualize_materials(slab, repetitions=VISUALIZE_REPETITIONS)\n",
- " visualize_materials(slab, repetitions=VISUALIZE_REPETITIONS, rotation=\"-90x\")\n"
+ " visualize_materials(slab, repetitions=CELL_REPETITIONS_FOR_VISUALIZATION)\n",
+ " visualize_materials(slab, repetitions=CELL_REPETITIONS_FOR_VISUALIZATION, rotation=\"-90x\")"
],
"metadata": {
"collapsed": false
@@ -217,7 +217,7 @@
" rotate_to_match_pbc=ROTATE_TO_MATCH_PBC\n",
")\n",
"\n",
- "builder = TerraceSlabDefectBuilder()\n"
+ "builder = TerraceSlabDefectBuilder()"
],
"metadata": {
"collapsed": false
@@ -245,7 +245,7 @@
"print(f\"Cut direction: {CUT_DIRECTION}\")\n",
"print(f\"Pivot point: {PIVOT_COORDINATE}\")\n",
"print(f\"Added layers: {NUMBER_OF_ADDED_LAYERS}\")\n",
- "print(f\"Number of atoms: {len(terrace_slab.basis.elements.ids)}\")\n"
+ "print(f\"Number of atoms: {len(terrace_slab.basis.elements.ids)}\")"
],
"metadata": {
"collapsed": false
@@ -268,8 +268,8 @@
"outputs": [],
"source": [
"print(\"Final structure with terrace:\")\n",
- "visualize_materials(terrace_slab, repetitions=[1, 1, 1])\n",
- "visualize_materials(terrace_slab, repetitions=[1, 1, 1], rotation=\"-90x\")\n"
+ "visualize_materials(terrace_slab, repetitions=CELL_REPETITIONS_FOR_VISUALIZATION)\n",
+ "visualize_materials(terrace_slab, repetitions=CELL_REPETITIONS_FOR_VISUALIZATION, rotation=\"-90x\")"
],
"metadata": {
"collapsed": false
From 3b88253e5a3656fc236f7cb15618239dc99ac3a4 Mon Sep 17 00:00:00 2001
From: VsevolodX <79542055+VsevolodX@users.noreply.github.com>
Date: Fri, 22 Nov 2024 17:59:07 -0800
Subject: [PATCH 3/8] chore: cleanup
---
.../create_terrace_defect.ipynb | 29 ++++++++-----------
1 file changed, 12 insertions(+), 17 deletions(-)
diff --git a/other/materials_designer/create_terrace_defect.ipynb b/other/materials_designer/create_terrace_defect.ipynb
index 82495483..00d8a04b 100644
--- a/other/materials_designer/create_terrace_defect.ipynb
+++ b/other/materials_designer/create_terrace_defect.ipynb
@@ -17,10 +17,7 @@
"\n",
"## Notes\n",
"\n",
- "1. The input material must be a slab (2D periodic structure with vacuum)\n",
- "2. The terrace is created by adding layers above a cutting plane\n",
- "3. The cutting plane is defined by its normal direction and a point it passes through\n",
- "4. The structure can be automatically rotated to match periodic boundary conditions\n"
+ "1. The input material must be a Slab, or slab will be generated with provided parameters.\n"
],
"metadata": {
"collapsed": false
@@ -31,8 +28,7 @@
"cell_type": "markdown",
"source": [
"## 1. Prepare the Environment\n",
- "### 1.1. Set up the notebook\n",
- "Set the following flags to control the notebook behavior\n"
+ "### 1.1. Set up the notebook"
],
"metadata": {
"collapsed": false
@@ -48,9 +44,9 @@
"\n",
"# Terrace parameters\n",
"CUT_DIRECTION = [1, 0, 0] # Normal vector describing a plane that cuts the terrace from added layers (Miller indices)\n",
- "PIVOT_COORDINATE = [0.5, 0.5, 0.5] # Point the cutting plane passes through (fractional)\n",
+ "PIVOT_COORDINATE = [0.5, 0.5, 0.5] # Point the cutting plane passes through, in crystal coordinates\n",
"NUMBER_OF_ADDED_LAYERS = 1 # Height of terrace in atomic layers\n",
- "USE_CARTESIAN_COORDINATES = False # Use cartesian instead of fractional coordinates\n",
+ "USE_CARTESIAN_COORDINATES = False # Use cartesian instead of crystal coordinates\n",
"ROTATE_TO_MATCH_PBC = True # Rotate to match periodic boundary conditions\n",
"\n",
"# Slab parameters for creating a new slab if provided material is not a slab\n",
@@ -95,7 +91,7 @@
" await micropip.install('mat3ra-api-examples', deps=False)\n",
" from utils.jupyterlite import install_packages\n",
"\n",
- " await install_packages(\"\", \"../../config.yml\")"
+ " await install_packages(\"\")"
],
"metadata": {
"collapsed": false
@@ -106,7 +102,7 @@
{
"cell_type": "markdown",
"source": [
- "### 1.3. Load and preview input material"
+ "### 1.3. Load input material"
],
"metadata": {
"collapsed": false
@@ -166,8 +162,7 @@
{
"cell_type": "markdown",
"source": [
- "## 2. Prepare Material\n",
- "### 2.1. Select and visualize initial slab"
+ "### 1.5. Visualize slab"
],
"metadata": {
"collapsed": false
@@ -194,8 +189,8 @@
{
"cell_type": "markdown",
"source": [
- "## 3. Generate Terrace Defect\n",
- "### 3.1. Set up terrace configuration and builder\n"
+ "## 2. Create target material\n",
+ "### 2.1. Set up terrace configuration and builder\n"
],
"metadata": {
"collapsed": false
@@ -228,7 +223,7 @@
{
"cell_type": "markdown",
"source": [
- "### 3.2. Generate terrace defect\n"
+ "### 2.2. Generate terrace defect\n"
],
"metadata": {
"collapsed": false
@@ -256,7 +251,7 @@
{
"cell_type": "markdown",
"source": [
- "## 4. Preview the terrace defect"
+ "## 3. Visualize the result"
],
"metadata": {
"collapsed": false
@@ -280,7 +275,7 @@
{
"cell_type": "markdown",
"source": [
- "### 5. Pass data to the outside runtime\n"
+ "## 4. Pass data to the outside runtime\n"
],
"metadata": {
"collapsed": false
From c50aa2222caebe336ef1987bbf7fd64d2213ebcc Mon Sep 17 00:00:00 2001
From: VsevolodX <79542055+VsevolodX@users.noreply.github.com>
Date: Mon, 25 Nov 2024 11:48:59 -0800
Subject: [PATCH 4/8] update: use make slab if not
---
.../create_terrace_defect.ipynb | 23 ++++++++-----------
1 file changed, 10 insertions(+), 13 deletions(-)
diff --git a/other/materials_designer/create_terrace_defect.ipynb b/other/materials_designer/create_terrace_defect.ipynb
index 00d8a04b..3211b6bf 100644
--- a/other/materials_designer/create_terrace_defect.ipynb
+++ b/other/materials_designer/create_terrace_defect.ipynb
@@ -137,21 +137,18 @@
"cell_type": "code",
"outputs": [],
"source": [
- "from mat3ra.made.tools.build.slab import create_slab, SlabConfiguration\n",
+ "from mat3ra.made.tools.build.slab import create_slab_if_not, SlabConfiguration\n",
"\n",
- "slab = materials[0]\n",
- "if not slab.metadata or slab.metadata[\"build\"][\"configuration\"][\"type\"] != SlabConfiguration.__name__:\n",
- " print(\"The material is not a slab. Creating a new slab...\")\n",
- " slab_config = SlabConfiguration(\n",
- " bulk=materials[0],\n",
- " miller_indices=DEFAULT_SLAB_PARAMETERS[\"miller_indices\"],\n",
- " thickness=DEFAULT_SLAB_PARAMETERS[\"thickness\"],\n",
- " vacuum=DEFAULT_SLAB_PARAMETERS[\"vacuum\"],\n",
- " use_orthogonal_z=DEFAULT_SLAB_PARAMETERS[\"use_orthogonal_z\"],\n",
- " xy_supercell_matrix=DEFAULT_SLAB_PARAMETERS[\"xy_supercell_matrix\"]\n",
- " )\n",
+ "default_slab_config = SlabConfiguration(\n",
+ " bulk=materials[0],\n",
+ " miller_indices=DEFAULT_SLAB_PARAMETERS[\"miller_indices\"],\n",
+ " thickness=DEFAULT_SLAB_PARAMETERS[\"thickness\"],\n",
+ " vacuum=DEFAULT_SLAB_PARAMETERS[\"vacuum\"],\n",
+ " use_orthogonal_z=DEFAULT_SLAB_PARAMETERS[\"use_orthogonal_z\"],\n",
+ " xy_supercell_matrix=DEFAULT_SLAB_PARAMETERS[\"xy_supercell_matrix\"]\n",
+ ")\n",
"\n",
- " slab = create_slab(slab_config)"
+ "slab = create_slab_if_not(materials[0], default_slab_config)"
],
"metadata": {
"collapsed": false
From df314156414457f95b2644a2ab1a2d430ea53959 Mon Sep 17 00:00:00 2001
From: VsevolodX <79542055+VsevolodX@users.noreply.github.com>
Date: Mon, 25 Nov 2024 11:50:13 -0800
Subject: [PATCH 5/8] update: use make slab if not - other nb
---
.../create_cutout_box.ipynb | 25 ++++++++-----------
1 file changed, 11 insertions(+), 14 deletions(-)
diff --git a/other/materials_designer/create_cutout_box.ipynb b/other/materials_designer/create_cutout_box.ipynb
index bc74089b..d5c539bd 100644
--- a/other/materials_designer/create_cutout_box.ipynb
+++ b/other/materials_designer/create_cutout_box.ipynb
@@ -85,7 +85,7 @@
" await micropip.install('mat3ra-api-examples', deps=False)\n",
" from utils.jupyterlite import install_packages\n",
"\n",
- " await install_packages(\"\")"
+ " await install_packages(\"\", \"../../config.yml\")"
],
"metadata": {
"collapsed": false
@@ -131,21 +131,18 @@
"cell_type": "code",
"outputs": [],
"source": [
- "from mat3ra.made.tools.build.slab import create_slab, SlabConfiguration\n",
+ "from mat3ra.made.tools.build.slab import create_slab_if_not, SlabConfiguration\n",
"\n",
- "slab = materials[0]\n",
- "if not slab.metadata or slab.metadata[\"build\"][\"configuration\"][\"type\"] != SlabConfiguration.__name__:\n",
- " print(\"The material is not a slab. Creating a new slab...\")\n",
- " slab_config = SlabConfiguration(\n",
- " bulk=materials[0],\n",
- " miller_indices=DEFAULT_SLAB_PARAMETERS[\"miller_indices\"],\n",
- " thickness=DEFAULT_SLAB_PARAMETERS[\"thickness\"],\n",
- " vacuum=DEFAULT_SLAB_PARAMETERS[\"vacuum\"],\n",
- " use_orthogonal_z=DEFAULT_SLAB_PARAMETERS[\"use_orthogonal_z\"],\n",
- " xy_supercell_matrix=DEFAULT_SLAB_PARAMETERS[\"xy_supercell_matrix\"]\n",
- " )\n",
+ "default_slab_config = SlabConfiguration(\n",
+ " bulk=materials[0],\n",
+ " miller_indices=DEFAULT_SLAB_PARAMETERS[\"miller_indices\"],\n",
+ " thickness=DEFAULT_SLAB_PARAMETERS[\"thickness\"],\n",
+ " vacuum=DEFAULT_SLAB_PARAMETERS[\"vacuum\"],\n",
+ " use_orthogonal_z=DEFAULT_SLAB_PARAMETERS[\"use_orthogonal_z\"],\n",
+ " xy_supercell_matrix=DEFAULT_SLAB_PARAMETERS[\"xy_supercell_matrix\"]\n",
+ ")\n",
"\n",
- " slab = create_slab(slab_config)"
+ "slab = create_slab_if_not(materials[0], default_slab_config)"
],
"metadata": {
"collapsed": false
From b10df2a6d4b98ed0ae0c0241f0c3ac18e23c4c72 Mon Sep 17 00:00:00 2001
From: VsevolodX <79542055+VsevolodX@users.noreply.github.com>
Date: Mon, 25 Nov 2024 13:24:20 -0800
Subject: [PATCH 6/8] update: add image to show terrace params
---
other/materials_designer/create_terrace_defect.ipynb | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/other/materials_designer/create_terrace_defect.ipynb b/other/materials_designer/create_terrace_defect.ipynb
index 3211b6bf..a6d3acda 100644
--- a/other/materials_designer/create_terrace_defect.ipynb
+++ b/other/materials_designer/create_terrace_defect.ipynb
@@ -17,7 +17,7 @@
"\n",
"## Notes\n",
"\n",
- "1. The input material must be a Slab, or slab will be generated with provided parameters.\n"
+ "1. The input material must be a Slab, or slab will be generated with provided parameters."
],
"metadata": {
"collapsed": false
@@ -28,7 +28,9 @@
"cell_type": "markdown",
"source": [
"## 1. Prepare the Environment\n",
- "### 1.1. Set up the notebook"
+ "### 1.1. Set up the notebook\n",
+ "The cut direction, pivot coordinate, and number of added layers define the terrace defect, shown in the image below.\n",
+ ""
],
"metadata": {
"collapsed": false
From 4059d460cf5a73a1a3057b11aa69cbbe9826f835 Mon Sep 17 00:00:00 2001
From: VsevolodX <79542055+VsevolodX@users.noreply.github.com>
Date: Mon, 25 Nov 2024 19:36:27 -0800
Subject: [PATCH 7/8] chore: remove erroneous
---
other/materials_designer/create_cutout_box.ipynb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/other/materials_designer/create_cutout_box.ipynb b/other/materials_designer/create_cutout_box.ipynb
index d5c539bd..b9ec7b44 100644
--- a/other/materials_designer/create_cutout_box.ipynb
+++ b/other/materials_designer/create_cutout_box.ipynb
@@ -85,7 +85,7 @@
" await micropip.install('mat3ra-api-examples', deps=False)\n",
" from utils.jupyterlite import install_packages\n",
"\n",
- " await install_packages(\"\", \"../../config.yml\")"
+ " await install_packages(\"\")"
],
"metadata": {
"collapsed": false
From c157d09dfbddb23a8bc93d37ad8a52d125a0e702 Mon Sep 17 00:00:00 2001
From: VsevolodX <79542055+VsevolodX@users.noreply.github.com>
Date: Mon, 25 Nov 2024 19:51:07 -0800
Subject: [PATCH 8/8] update: fix missing link to intro nb
---
other/materials_designer/Introduction.ipynb | 1 +
1 file changed, 1 insertion(+)
diff --git a/other/materials_designer/Introduction.ipynb b/other/materials_designer/Introduction.ipynb
index 4ce5a626..e2a4f339 100644
--- a/other/materials_designer/Introduction.ipynb
+++ b/other/materials_designer/Introduction.ipynb
@@ -63,6 +63,7 @@
"\n",
"### 3.3. Planar Defects\n",
"#### [3.3.1. Grain Boundary in a 3D Crystal](create_grain_boundary_crystal.ipynb)\n",
+ "#### [3.3.2. Grain Boundary in a 2D Material](create_grain_boundary_film.ipynb)\n",
"\n",
"\n",
"## 4. Passivation.\n",