-
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 #183 from Exabyte-io/feature/SOF-7526
feature/SOF 7526
- Loading branch information
Showing
1 changed file
with
376 additions
and
0 deletions.
There are no files selected for viewing
376 changes: 376 additions & 0 deletions
376
other/materials_designer/specific_examples/interface_2d_3d_graphene_silicon_dioxide.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,376 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# Interface between Graphene and SiO2 (\n", | ||
"\n", | ||
"## Introduction\n", | ||
"\n", | ||
"This notebook demonstrates the creation of an interface between 2D and 3D material: Graphene on SiO2. \n", | ||
"\n", | ||
"Following the manuscript:\n", | ||
" > **Yong-Ju Kang, Joongoo Kang, and K. J. Chang** \n", | ||
" > \"Electronic structure of graphene and doping effect on SiO2\"\n", | ||
" > Phys. Rev. B 78, 115404 (2008)\n", | ||
" > [DOI: 10.1103/PhysRevB.78.115404](https://doi.org/10.1103/PhysRevB.78.115404)\n", | ||
"\n", | ||
"\n", | ||
"\n", | ||
"Replicating the materials from the manuscript, FIG. 1. (b):\n", | ||
"\n", | ||
"<img src='https://i.imgur.com/ltSj5uk.png' width='600'/>\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"source": [ | ||
"## 1. Prepare the Environment\n", | ||
"### 1.1. Set up the notebook \n", | ||
"\n", | ||
"Set the following flags to control the notebook behavior " | ||
], | ||
"metadata": { | ||
"collapsed": false | ||
} | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"outputs": [], | ||
"source": [ | ||
"FILM_INDEX = 1 # Index in the list of materials, to access as materials[FILM_INDEX]\n", | ||
"FILM_MILLER_INDICES = (0, 0, 1)\n", | ||
"FILM_THICKNESS = 1 # in atomic layers\n", | ||
"FILM_VACUUM = 0.0 # in angstroms\n", | ||
"FILM_XY_SUPERCELL_MATRIX = [[1, 0], [0, 1]]\n", | ||
"FILM_USE_ORTHOGONAL_Z = True\n", | ||
"\n", | ||
"SUBSTRATE_INDEX = 0\n", | ||
"SUBSTRATE_MILLER_INDICES = (0, 0, 1)\n", | ||
"SUBSTRATE_THICKNESS = 7 # in atomic layers (for 14 bilayers -- from manuscript)\n", | ||
"SUBSTRATE_VACUUM = 0.0 # in angstroms\n", | ||
"SUBSTRATE_XY_SUPERCELL_MATRIX = [[1, 0], [0, 1]]\n", | ||
"SUBSTRATE_USE_ORTHOGONAL_Z = True\n", | ||
"\n", | ||
"# Maximum area for the superlattice search algorithm\n", | ||
"MAX_AREA = 150 # in Angstrom^2\n", | ||
"# Set the termination pair indices\n", | ||
"TERMINATION_PAIR_INDICES = [1] # For O-terminated\n", | ||
"INTERFACE_DISTANCE = 2.58 # in Angstrom -- from manuscript\n", | ||
"INTERFACE_VACUUM = 20.0 # in Angstrom -- from manuscript" | ||
], | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"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 | ||
} | ||
}, | ||
{ | ||
"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(\"specific_examples|create_interface_with_min_strain_zsl.ipynb\")" | ||
], | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"execution_count": null | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"source": [ | ||
"### 1.3. Get input materials and assign `substrate` and `film`" | ||
], | ||
"metadata": {} | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"outputs": [], | ||
"source": [ | ||
"from mat3ra.standata.materials import Materials\n", | ||
"from mat3ra.made.material import Material\n", | ||
"\n", | ||
"film = Material(Materials.get_by_name_first_match(\"Graphene\"))\n", | ||
"substrate = Material(Materials.get_by_name_first_match(\"SiO2\"))" | ||
], | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"execution_count": null | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"source": [ | ||
"### 1.4. Preview Substrate and Film" | ||
], | ||
"metadata": { | ||
"collapsed": false | ||
} | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"outputs": [], | ||
"source": [ | ||
"from utils.visualize import visualize_materials as visualize\n", | ||
"\n", | ||
"visualize([substrate, film], repetitions=[3, 3, 1], rotation=\"0x\")" | ||
], | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"execution_count": null | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"source": [ | ||
"## 2. Configure slabs and select termination pair\n", | ||
"\n", | ||
"### 2.1. Create Substrate and Layer Slabs\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", | ||
"Define the substrate slab cell that will be used as a base for the interface and the film slab cell that will be placed on top of the substrate slab." | ||
], | ||
"metadata": {} | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"outputs": [], | ||
"source": [ | ||
"from mat3ra.made.tools.build.slab import SlabConfiguration, get_terminations, create_slab, \\\n", | ||
" PymatgenSlabGeneratorParameters\n", | ||
"\n", | ||
"film_slab_configuration = SlabConfiguration(\n", | ||
" bulk=film,\n", | ||
" miller_indices=FILM_MILLER_INDICES,\n", | ||
" thickness=FILM_THICKNESS, # in atomic layers\n", | ||
" vacuum=FILM_VACUUM, # in angstroms\n", | ||
" xy_supercell_matrix=FILM_XY_SUPERCELL_MATRIX,\n", | ||
" use_orthogonal_z=FILM_USE_ORTHOGONAL_Z\n", | ||
")\n", | ||
"\n", | ||
"substrate_slab_configuration = SlabConfiguration(\n", | ||
" bulk=substrate,\n", | ||
" miller_indices=SUBSTRATE_MILLER_INDICES,\n", | ||
" thickness=SUBSTRATE_THICKNESS, # in atomic layers\n", | ||
" vacuum=SUBSTRATE_VACUUM, # in angstroms\n", | ||
" xy_supercell_matrix=SUBSTRATE_XY_SUPERCELL_MATRIX,\n", | ||
" use_orthogonal_z=SUBSTRATE_USE_ORTHOGONAL_Z,\n", | ||
")\n", | ||
"\n", | ||
"params = PymatgenSlabGeneratorParameters(\n", | ||
" symmetrize=False)" | ||
], | ||
"metadata": {}, | ||
"execution_count": null | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"source": [ | ||
"### 2.2. Get possible terminations for the slabs" | ||
], | ||
"metadata": { | ||
"collapsed": false | ||
} | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"outputs": [], | ||
"source": [ | ||
"film_slab_terminations = get_terminations(film_slab_configuration, params)\n", | ||
"substrate_slab_terminations = get_terminations(substrate_slab_configuration, params)" | ||
], | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"execution_count": null | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"source": [ | ||
"### 2.3. Visualize slabs for all possible terminations" | ||
], | ||
"metadata": { | ||
"collapsed": false | ||
} | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"outputs": [], | ||
"source": [ | ||
"film_slabs = [create_slab(film_slab_configuration, termination) for termination in film_slab_terminations]\n", | ||
"substrate_slabs = [create_slab(substrate_slab_configuration, termination, params) for termination in\n", | ||
" substrate_slab_terminations]\n", | ||
"\n", | ||
"visualize([{\"material\": slab, \"title\": slab.metadata[\"build\"][\"termination\"]} for slab in film_slabs],\n", | ||
" repetitions=[3, 3, 1], rotation=\"-90x\")\n", | ||
"visualize([{\"material\": slab, \"title\": slab.metadata[\"build\"][\"termination\"]} for slab in substrate_slabs],\n", | ||
" repetitions=[3, 3, 1], rotation=\"-90x\")" | ||
], | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"execution_count": null | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"source": [ | ||
"### 2.4. Print terminations for the interface" | ||
], | ||
"metadata": { | ||
"collapsed": false | ||
} | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"outputs": [], | ||
"source": [ | ||
"from itertools import product\n", | ||
"\n", | ||
"termination_pairs = list(product(film_slab_terminations, substrate_slab_terminations))\n", | ||
"print(\"Termination Pairs (Film, Substrate)\")\n", | ||
"for idx, termination_pair in enumerate(termination_pairs):\n", | ||
" print(f\" {idx}: {termination_pair}\")" | ||
], | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"execution_count": null | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"source": [ | ||
"## 3. Create interfaces\n", | ||
"\n", | ||
"### 3.1. Initialize the Interface Configuration" | ||
], | ||
"metadata": { | ||
"collapsed": false | ||
} | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"outputs": [], | ||
"source": [ | ||
"from mat3ra.made.tools.build.interface import InterfaceConfiguration\n", | ||
"from mat3ra.made.tools.build.interface import ZSLStrainMatchingParameters\n", | ||
"from mat3ra.made.tools.build.interface import ZSLStrainMatchingInterfaceBuilder, \\\n", | ||
" ZSLStrainMatchingInterfaceBuilderParameters\n", | ||
"\n", | ||
"interfaces = []\n", | ||
"for termination_pair_idx in TERMINATION_PAIR_INDICES:\n", | ||
" termination_pair = termination_pairs[termination_pair_idx]\n", | ||
" film_termination, substrate_termination = termination_pair\n", | ||
" interface_configuration = InterfaceConfiguration(\n", | ||
" film_configuration=film_slab_configuration,\n", | ||
" substrate_configuration=substrate_slab_configuration,\n", | ||
" film_termination=film_termination,\n", | ||
" substrate_termination=substrate_termination,\n", | ||
" distance_z=INTERFACE_DISTANCE,\n", | ||
" vacuum=INTERFACE_VACUUM\n", | ||
" )\n", | ||
"\n", | ||
" zsl_strain_matching_parameters = ZSLStrainMatchingParameters(\n", | ||
" max_area=MAX_AREA,\n", | ||
" )\n", | ||
"\n", | ||
" matched_interfaces_builder = ZSLStrainMatchingInterfaceBuilder(\n", | ||
" build_parameters=ZSLStrainMatchingInterfaceBuilderParameters(\n", | ||
" strain_matching_parameters=zsl_strain_matching_parameters))\n", | ||
" interfaces_sorted_by_size_and_strain = matched_interfaces_builder.get_materials(\n", | ||
" configuration=interface_configuration)\n", | ||
" selected_interface = interfaces_sorted_by_size_and_strain[0]\n", | ||
" selected_interface.name = f\"Interface {termination_pair}\"\n", | ||
" interfaces.append(selected_interface)\n" | ||
], | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"execution_count": null | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"source": [ | ||
"## 4. Visualize the interfaces" | ||
], | ||
"metadata": { | ||
"collapsed": false | ||
} | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"outputs": [], | ||
"source": [ | ||
"visualize(interfaces, repetitions=[3, 3, 1])\n", | ||
"visualize(interfaces, repetitions=[1, 1, 1], rotation=\"-90x\")" | ||
], | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"execution_count": null | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## 5. Pass data to the outside runtime" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from utils.jupyterlite import download_content_to_file\n", | ||
"\n", | ||
"for idx, interface in enumerate(interfaces):\n", | ||
" download_content_to_file(interfaces, f\"interface_{idx}.json\")" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": ".venv", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.10.12" | ||
}, | ||
"widgets": { | ||
"application/vnd.jupyter.widget-state+json": { | ||
"state": {}, | ||
"version_major": 2, | ||
"version_minor": 0 | ||
} | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 4 | ||
} |