diff --git a/other/materials_designer/create_point_defect_pair.ipynb b/other/materials_designer/create_point_defect_pair.ipynb index 7c4cadbd..647fe88c 100644 --- a/other/materials_designer/create_point_defect_pair.ipynb +++ b/other/materials_designer/create_point_defect_pair.ipynb @@ -40,12 +40,6 @@ "cell_type": "code", "outputs": [], "source": [ - "DEFECT_TYPE = \"substitution\" # (e.g. \"vacancy\", \"substitution\", \"interstitial\")\n", - "SITE_ID = None # Site index of the defect\n", - "COORDINATE = None # Position of the defect in crystal coordinates\n", - "APPROXIMATE_COORDINATE = None # Approximate coordinates of the defect in crystal coordinates\n", - "CHEMICAL_ELEMENT = \"C\" # Element to be placed at the site (ignored for vacancy)\n", - "\n", "SUPERCELL_MATRIX = [[3, 0, 0], [0, 3, 0], [0, 0, 3]]\n", "\n", "# List of dictionaries with defect parameters\n", diff --git a/other/materials_designer/specific_examples/defect_point_pair_gallium_nitride.ipynb b/other/materials_designer/specific_examples/defect_point_pair_gallium_nitride.ipynb new file mode 100644 index 00000000..916fa9b0 --- /dev/null +++ b/other/materials_designer/specific_examples/defect_point_pair_gallium_nitride.ipynb @@ -0,0 +1,269 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "source": [ + "# Vacancy and Substitutional defect pair in GaN\n", + "\n", + "Focusing on recreating the defect pair in GaN from the Figure 1. c) in the publication:\n", + "\n", + "" + ], + "metadata": { + "collapsed": false + }, + "id": "4f901763903359e6" + }, + { + "cell_type": "markdown", + "source": [ + "## 1. Prepare the Environment\n", + "### 1.1. Set up defects parameters \n", + "Defect Configuration parameters are described in [Defect Configuration](https://github.com/Exabyte-io/made/blob/8196b759242551c77d1791bf5bd2f4150763cfef/src/py/mat3ra/made/tools/build/defect/configuration.py#L102)." + ], + "metadata": { + "collapsed": false + }, + "id": "7863267c827cfbc2" + }, + { + "cell_type": "code", + "outputs": [], + "source": [ + "SUPERCELL_MATRIX = [[3, 0, 0], [0, 3, 0], [0, 0, 2]]\n", + "\n", + "# List of dictionaries with defect parameters\n", + "PRIMARY_DEFECT_CONFIG = {\n", + " \"defect_type\": \"substitution\",\n", + " \"approximate_coordinate\": [0.5, 0.5, 0.5],\n", + " \"chemical_element\": \"Mg\",\n", + "}\n", + "\n", + "SECONDARY_DEFECT_CONFIG = {\n", + " \"defect_type\": \"vacancy\",\n", + " \"approximate_coordinate\": [0.5, 0.5, 0.65],\n", + "}" + ], + "metadata": { + "collapsed": false + }, + "id": "2719b1a0b211ce20", + "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": "5626829bece625b" + }, + { + "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(\"create_point_defect.ipynb\")" + ], + "metadata": { + "collapsed": false + }, + "id": "f4994342ac9f2cbd", + "execution_count": null + }, + { + "cell_type": "markdown", + "source": [ + "### 1.3. Get input materials\n", + "Materials are loaded with `get_materials()`." + ], + "metadata": { + "collapsed": false + }, + "id": "683ce558645b4465" + }, + { + "cell_type": "code", + "outputs": [], + "source": [ + "from mat3ra.standata.materials import Materials\n", + "from mat3ra.made.material import Material\n", + "\n", + "material = Material(Materials.get_by_name_first_match(\"GaN\"))" + ], + "metadata": { + "collapsed": false + }, + "id": "4a6bab14f63024d1", + "execution_count": null + }, + { + "cell_type": "markdown", + "source": [ + "### 1.4. Create and preview Supercell" + ], + "metadata": { + "collapsed": false + }, + "id": "acfef1aa207eb977" + }, + { + "cell_type": "code", + "outputs": [], + "source": [ + "from utils.visualize import visualize_materials as visualize\n", + "from mat3ra.made.tools.build.supercell import create_supercell\n", + "\n", + "unit_cell = material\n", + "supercell = create_supercell(unit_cell, supercell_matrix=SUPERCELL_MATRIX)\n", + "visualize(supercell, repetitions=[1, 1, 1], rotation=\"0x\")" + ], + "metadata": { + "collapsed": false + }, + "id": "4580fda63efa927e", + "execution_count": null + }, + { + "cell_type": "markdown", + "source": [ + "## 2. Create the Defect\n", + "### 2.1. Initialize Configuration and Builder parameters" + ], + "metadata": { + "collapsed": false + }, + "id": "4391a0f444f4b64a" + }, + { + "cell_type": "code", + "outputs": [], + "source": [ + "from mat3ra.made.tools.build.defect.configuration import PointDefectPairConfiguration, PointDefectConfiguration\n", + "from mat3ra.made.tools.build.defect.builders import PointDefectBuilderParameters\n", + "\n", + "primary_defect_configuration = PointDefectConfiguration.from_dict(supercell, PRIMARY_DEFECT_CONFIG)\n", + "secondary_defect_configuration = PointDefectConfiguration.from_dict(supercell, SECONDARY_DEFECT_CONFIG)\n", + "\n", + "point_defect_pair_configuration = PointDefectPairConfiguration(\n", + " primary_defect_configuration=primary_defect_configuration,\n", + " secondary_defect_configuration=secondary_defect_configuration\n", + ")\n", + "\n", + "defect_builder_parameters = PointDefectBuilderParameters(center_defect=False)" + ], + "metadata": { + "collapsed": false + }, + "id": "c686498fc4419e3c", + "execution_count": null + }, + { + "cell_type": "markdown", + "source": [ + "### 2.2. Create the defects" + ], + "metadata": { + "collapsed": false + }, + "id": "358ae5cd995c821f" + }, + { + "cell_type": "code", + "outputs": [], + "source": [ + "from mat3ra.made.tools.build.defect.builders import PointDefectPairBuilder\n", + "\n", + "material_with_defect = PointDefectPairBuilder(defect_builder_parameters).get_material(point_defect_pair_configuration)" + ], + "metadata": { + "collapsed": false + }, + "id": "7a584be241ab1548", + "execution_count": null + }, + { + "cell_type": "markdown", + "source": [ + "## 3. Visualize Result(s)" + ], + "metadata": { + "collapsed": false + }, + "id": "f99753a31e0123a" + }, + { + "cell_type": "code", + "outputs": [], + "source": [ + "from utils.visualize import visualize_materials as visualize\n", + "\n", + "visualize([{\"material\": supercell, \"title\": \"Original material\"},\n", + " {\"material\": material_with_defect, \"title\": f\"Material with defect\"}],\n", + " rotation=\"-90x\")\n", + "visualize([{\"material\": supercell, \"title\": \"Original material\"},\n", + " {\"material\": material_with_defect, \"title\": f\"Material with defect\"}])" + ], + "metadata": { + "collapsed": false + }, + "id": "951f0cffe9389d5e", + "execution_count": null + }, + { + "cell_type": "markdown", + "source": [ + "## 4. Pass data to the outside runtime" + ], + "metadata": { + "collapsed": false + }, + "id": "1c5d8e66b5b105ee" + }, + { + "cell_type": "code", + "outputs": [], + "source": [ + "from utils.jupyterlite import download_content_to_file\n", + "\n", + "download_content_to_file(material_with_defect, \"Mg substitution and vacancy in GaN.json\")" + ], + "metadata": { + "collapsed": false + }, + "id": "b9e1aba13faf1bf0", + "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 +}