-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #172 from Exabyte-io/feature/SOF-7507
feature/SOF-7507 feat: Mg in GaN defect tutorial
- Loading branch information
Showing
2 changed files
with
269 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
269 changes: 269 additions & 0 deletions
269
other/materials_designer/specific_examples/defect_point_pair_gallium_nitride.ipynb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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", | ||
"<img src=\"https://i.imgur.com/1JsDwXO.png\" width=\"400\" />" | ||
], | ||
"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 | ||
} |