-
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 #136 from Exabyte-io/feature/SOF-7402
feature/SOF 7402
- Loading branch information
Showing
4 changed files
with
304 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
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,293 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"source": [ | ||
"# Create adatom defects in a slab material\n", | ||
"\n", | ||
"Create an adatom by specifying the chemical element, approximate position on surface and distance z, which will be resolved to:\n", | ||
"- the equidistant position between the closes atoms on the surface according to Voronoi tesselation, \n", | ||
"- or the crystal site of the next layer that is closest to specified position.\n", | ||
"\n", | ||
"<h2 style=\"color:green\">Usage</h2>\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. Set defects parameters in cell 2.1. (or use default).\n", | ||
"1. Click “Run” > “Run All” to run all cells. \n", | ||
"1. Wait for the run to complete (depending on the parameters can take a few min). \n", | ||
"1. Scroll down to view results. \n", | ||
"\n", | ||
"## Summary\n", | ||
"1. Prepare the Environment: Set up the notebook and install packages, preview the input materials\n", | ||
"1. Create the Defect: Add an adatom defect to the slab material\n", | ||
"2. Visualize the Defect: Visualize the defect structure\n", | ||
"\n", | ||
"## Notes\n", | ||
"\n", | ||
"1. For more information, see [Introduction](Introduction.ipynb)\n", | ||
"<!-- # TODO: use a hashtag-based anchor link to interface creation documention above -->\n" | ||
], | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"id": "f2e1e795020d7b3f" | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"source": [ | ||
"## 1. Prepare the Environment\n", | ||
"### 1.1. Set up defect parameters " | ||
], | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"id": "5e43ff288847b784" | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"outputs": [], | ||
"source": [ | ||
"DEFECT_TYPE = \"adatom\" \n", | ||
"APPROXIMATE_POSITION_ON_SURFACE = [0.5, 0.5] # Position of the defect in crystal coordinates\n", | ||
"DISTANCE_Z = 2.0 # Distance of the defect from the surface in Angstrom\n", | ||
"CHEMICAL_ELEMENT = \"Si\" # Element to be placed at the site \n", | ||
"MILLER_INDICES = (1, 1, 1) # Miller indices of the surface\n", | ||
"SLAB_THICKNESS = 3 # Thickness of the slab in unit cells\n", | ||
"VACUUM = 6 # Vacuum thickness in Angstrom\n", | ||
"SUPERCELL_MATRIX = [[2, 0, 0], [0, 2, 0], [0, 0, 1]] " | ||
], | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"id": "9d8b1890b34d850a", | ||
"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": "bb64de5ff32649f8" | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"outputs": [], | ||
"source": [ | ||
"import sys\n", | ||
"\n", | ||
"if sys.platform == \"emscripten\":\n", | ||
" import micropip\n", | ||
" await micropip.install('mat3ra-api-examples', deps=False)\n", | ||
" from utils.jupyterlite import install_packages\n", | ||
" await install_packages(\"create_point_defect.ipynb\", \"../../config.yml\")" | ||
], | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"id": "ef664b14457530fd", | ||
"execution_count": null | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"source": [ | ||
"### 1.3. Get input material and \n", | ||
"Materials are loaded with `get_data()`. The first material is assigned as substrate and the second as film." | ||
], | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"id": "919ad7af8dceeedd" | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"outputs": [], | ||
"source": [ | ||
"from mat3ra.made.material import Material\n", | ||
"from utils.jupyterlite import get_data\n", | ||
"\n", | ||
"# Get the list of input materials and load them into `materials_in` variable\n", | ||
"get_data(\"materials_in\", globals())\n", | ||
"materials = list(map(Material, globals()[\"materials_in\"]))" | ||
], | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"id": "be38fdda1984c654", | ||
"execution_count": null | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"source": [ | ||
"### 1.4. Create and preview Slab" | ||
], | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"id": "a132fe0ef8bbf0d0" | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"outputs": [], | ||
"source": [ | ||
"from mat3ra.made.tools.build.slab import SlabConfiguration, get_terminations, create_slab\n", | ||
"from utils.visualize import visualize_materials as visualize\n", | ||
"\n", | ||
"material = materials[0]\n", | ||
"slab_config = SlabConfiguration(\n", | ||
" bulk=material,\n", | ||
" miller_indices=MILLER_INDICES,\n", | ||
" thickness=SLAB_THICKNESS,\n", | ||
" vacuum=VACUUM,\n", | ||
" use_orthogonal_z=True,\n", | ||
" xy_supercell_matrix=SUPERCELL_MATRIX\n", | ||
" )\n", | ||
"termination = get_terminations(slab_config)[0]\n", | ||
"slab = create_slab(slab_config, termination)\n", | ||
"visualize([{\"material\":slab , \"rotation\":\"0x\"}, {\"material\": slab, \"rotation\": \"-90x\"}],repetitions=[1, 1, 1])" | ||
], | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"id": "e2d24109d3068c9e", | ||
"execution_count": null | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"source": [ | ||
"## 2. Create the Defect\n", | ||
"### 2.1. Set adatom parameters" | ||
], | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"id": "5da5b0380583c952" | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"outputs": [], | ||
"source": [ | ||
"from mat3ra.made.tools.build.defect import AdatomSlabPointDefectConfiguration\n", | ||
"from mat3ra.made.tools.build.defect.builders import EquidistantAdatomSlabDefectBuilder, CrystalSiteAdatomSlabDefectBuilder\n", | ||
"\n", | ||
"adatom_config = AdatomSlabPointDefectConfiguration(crystal=slab, \n", | ||
" defect_type=DEFECT_TYPE, \n", | ||
" chemical_element=CHEMICAL_ELEMENT, \n", | ||
" distance_z=DISTANCE_Z, \n", | ||
" position_on_surface=APPROXIMATE_POSITION_ON_SURFACE\n", | ||
")" | ||
], | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"id": "e385e50ae11ed2b9", | ||
"execution_count": null | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"source": [ | ||
"### 2.2. Create the adatom" | ||
], | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"id": "489b51f0ee122c48" | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"outputs": [], | ||
"source": [ | ||
"from mat3ra.made.tools.build.defect import create_slab_defect\n", | ||
"slab_with_adatom_at_specified_position = create_slab_defect(adatom_config)\n", | ||
"slab_with_adatom_at_equidistant_position = create_slab_defect(adatom_config, EquidistantAdatomSlabDefectBuilder())\n", | ||
"slab_with_adatom_at_crystal_site = create_slab_defect(adatom_config, CrystalSiteAdatomSlabDefectBuilder())" | ||
], | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"id": "a990fa35742d7269", | ||
"execution_count": null | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"source": [ | ||
"## 3. Visualize the Slabs with Adatom" | ||
], | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"id": "462549d016073446" | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"outputs": [], | ||
"source": [ | ||
"from utils.visualize import visualize_materials as visualize\n", | ||
"\n", | ||
"visualize([{\"material\": slab, \"title\": \"Original material\"},\n", | ||
" {\"material\": slab_with_adatom_at_equidistant_position, \"title\": f\"Material with adatom defect at equidistant position\"},\n", | ||
" {\"material\": slab_with_adatom_at_crystal_site, \"title\": f\"Material with adatom defect at crystal site\"}],\n", | ||
" rotation=\"-90x\"\n", | ||
" )\n", | ||
"visualize([{\"material\": slab, \"title\": \"Original material\"},\n", | ||
" {\"material\": slab_with_adatom_at_equidistant_position, \"title\": f\"Material with adatom defect at equidistant position\"},\n", | ||
" {\"material\": slab_with_adatom_at_crystal_site, \"title\": f\"Material with adatom defect at crystal site\"}]\n", | ||
")" | ||
], | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"id": "509b18661a069e42", | ||
"execution_count": null | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"source": [ | ||
"## 4. Pass data to the outside runtime" | ||
], | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"id": "d381df29a6bbdd82" | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"outputs": [], | ||
"source": [ | ||
"from utils.jupyterlite import set_data\n", | ||
"\n", | ||
"set_data(\"materials\", [slab_with_adatom_at_equidistant_position.to_json(), slab_with_adatom_at_crystal_site.to_json()])" | ||
], | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"id": "61daa5afcbc078a9", | ||
"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 | ||
} |
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
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