-
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 #161 from Exabyte-io/feature/SOF-7490
feature/SOF 7490
- Loading branch information
Showing
2 changed files
with
284 additions
and
1 deletion.
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,274 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"source": [ | ||
"# Create a Monolayer\n", | ||
"\n", | ||
"Create a Monolayer of the original structure. \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. Click “Run” > “Run All” to run all cells. \n", | ||
"1. Scroll down to view results. " | ||
], | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"id": "a79609c9bc772c5c" | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"source": [ | ||
"## 1. Prepare the Environment\n", | ||
"### 1.1. Set up transformation parameters " | ||
], | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"id": "47d31d9834478007" | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"outputs": [], | ||
"source": [ | ||
"XY_SUPERCELL_MATRIX = [\n", | ||
" [3, 0],\n", | ||
" [0, 3],\n", | ||
"]\n", | ||
"\n", | ||
"VACUUM = 10.0 # Angstrom" | ||
], | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"id": "a2c8922a4e627887", | ||
"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": "6fab076ea1d7a223" | ||
}, | ||
{ | ||
"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(\"\", \"../../config.yml\")" | ||
], | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"id": "b0c332f1c1f451fd", | ||
"execution_count": null | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"source": [ | ||
"### 1.3. Get input materials" | ||
], | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"id": "3e9934b458d6cb4" | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"outputs": [], | ||
"source": [ | ||
"from utils.jupyterlite import get_materials\n", | ||
"\n", | ||
"materials = get_materials(globals())\n", | ||
"material = materials[0]" | ||
], | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"id": "74cd0d5a3881ab47", | ||
"execution_count": null | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"source": [ | ||
"### 1.4. Preview the material" | ||
], | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"id": "d4535caf6debb8d4" | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"outputs": [], | ||
"source": [ | ||
"from utils.visualize import visualize_materials as visualize\n", | ||
"\n", | ||
"visualize(material, repetitions=[3, 3, 1], rotation=\"0x\")\n", | ||
"visualize(material, repetitions=[3, 3, 1], rotation=\"-90x\")" | ||
], | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"id": "d6bea39864c23ab5", | ||
"execution_count": null | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"source": [ | ||
"## 2. Create Monolayer" | ||
], | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"id": "5473c36cd254aa89" | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"source": [ | ||
"### 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": "ee17958872d03410" | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"outputs": [], | ||
"source": [ | ||
"from mat3ra.made.tools.build.slab import SlabConfiguration\n", | ||
"\n", | ||
"slab_configuration = SlabConfiguration(\n", | ||
" bulk=material,\n", | ||
" miller_indices=(0, 0, 1),\n", | ||
" thickness=1,\n", | ||
" vacuum=VACUUM,\n", | ||
" xy_supercell_matrix=XY_SUPERCELL_MATRIX,\n", | ||
" use_orthogonal_z=True,\n", | ||
" use_conventional_cell=True,\n", | ||
")" | ||
], | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"id": "b8dc56881543c16c", | ||
"execution_count": null | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"source": [ | ||
"### 2.2 Create the slab of Single Layer" | ||
], | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"id": "661c76f9bab9f743" | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"outputs": [], | ||
"source": [ | ||
"from mat3ra.made.tools.modify import translate_to_z_level, filter_by_box\n", | ||
"from mat3ra.made.tools.build.slab import create_slab\n", | ||
"\n", | ||
"slab = create_slab(slab_configuration)\n", | ||
"\n", | ||
"# Get only the top layer of two -- for AB stacked bilayers forming a 3D bulk basis\n", | ||
"if any(substring in material.name for substring in [\"3D\", \"Bulk\"]):\n", | ||
" centered_slab = translate_to_z_level(slab, z_level=\"center\")\n", | ||
" half_filtered_slab = filter_by_box(centered_slab, [0, 0, 0.5], [1, 1, 1])\n", | ||
" monolayer = translate_to_z_level(half_filtered_slab, z_level=\"center\")" | ||
], | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"id": "cf27e53c85adc447", | ||
"execution_count": null | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"source": [ | ||
"## 3. Visualize the result" | ||
], | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"id": "527829d64a542d10" | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"outputs": [], | ||
"source": [ | ||
"visualize(monolayer, repetitions=[1, 1, 1], rotation=\"0x\")\n", | ||
"visualize(monolayer, repetitions=[1, 1, 1], rotation=\"-90x\")" | ||
], | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"id": "ee12ab13c210b953", | ||
"execution_count": null | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"source": [ | ||
"# 4. Pass material to the outside runtime" | ||
], | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"id": "6ce5f7dd9a919a08" | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"outputs": [], | ||
"source": [ | ||
"from utils.jupyterlite import set_materials\n", | ||
"\n", | ||
"set_materials(monolayer)" | ||
], | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"id": "865c71d008d87beb", | ||
"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 | ||
} |