|
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "cell_type": "markdown", |
| 5 | + "metadata": {}, |
| 6 | + "source": [ |
| 7 | + "# Interface between Graphene and SiO2 (\n", |
| 8 | + "\n", |
| 9 | + "## Introduction\n", |
| 10 | + "\n", |
| 11 | + "This notebook demonstrates the creation of an interface between 2D and 3D material: Graphene on SiO2. \n", |
| 12 | + "\n", |
| 13 | + "Following the manuscript:\n", |
| 14 | + " > **Yong-Ju Kang, Joongoo Kang, and K. J. Chang** \n", |
| 15 | + " > \"Electronic structure of graphene and doping effect on SiO2\"\n", |
| 16 | + " > Phys. Rev. B 78, 115404 (2008)\n", |
| 17 | + " > [DOI: 10.1103/PhysRevB.78.115404](https://doi.org/10.1103/PhysRevB.78.115404)\n", |
| 18 | + "\n", |
| 19 | + "\n", |
| 20 | + "\n", |
| 21 | + "Replicating the materials from the manuscript, FIG. 1. (b):\n", |
| 22 | + "\n", |
| 23 | + "<img src='https://i.imgur.com/ltSj5uk.png' width='600'/>\n" |
| 24 | + ] |
| 25 | + }, |
| 26 | + { |
| 27 | + "cell_type": "markdown", |
| 28 | + "source": [ |
| 29 | + "## 1. Prepare the Environment\n", |
| 30 | + "### 1.1. Set up the notebook \n", |
| 31 | + "\n", |
| 32 | + "Set the following flags to control the notebook behavior " |
| 33 | + ], |
| 34 | + "metadata": { |
| 35 | + "collapsed": false |
| 36 | + } |
| 37 | + }, |
| 38 | + { |
| 39 | + "cell_type": "code", |
| 40 | + "outputs": [], |
| 41 | + "source": [ |
| 42 | + "FILM_INDEX = 1 # Index in the list of materials, to access as materials[FILM_INDEX]\n", |
| 43 | + "FILM_MILLER_INDICES = (0, 0, 1)\n", |
| 44 | + "FILM_THICKNESS = 1 # in atomic layers\n", |
| 45 | + "FILM_VACUUM = 0.0 # in angstroms\n", |
| 46 | + "FILM_XY_SUPERCELL_MATRIX = [[1, 0], [0, 1]]\n", |
| 47 | + "FILM_USE_ORTHOGONAL_Z = True\n", |
| 48 | + "\n", |
| 49 | + "SUBSTRATE_INDEX = 0\n", |
| 50 | + "SUBSTRATE_MILLER_INDICES = (0, 0, 1)\n", |
| 51 | + "SUBSTRATE_THICKNESS = 7 # in atomic layers (for 14 bilayers -- from manuscript)\n", |
| 52 | + "SUBSTRATE_VACUUM = 0.0 # in angstroms\n", |
| 53 | + "SUBSTRATE_XY_SUPERCELL_MATRIX = [[1, 0], [0, 1]]\n", |
| 54 | + "SUBSTRATE_USE_ORTHOGONAL_Z = True\n", |
| 55 | + "\n", |
| 56 | + "# Maximum area for the superlattice search algorithm\n", |
| 57 | + "MAX_AREA = 150 # in Angstrom^2\n", |
| 58 | + "# Set the termination pair indices\n", |
| 59 | + "TERMINATION_PAIR_INDICES = [1] # For O-terminated\n", |
| 60 | + "INTERFACE_DISTANCE = 2.58 # in Angstrom -- from manuscript\n", |
| 61 | + "INTERFACE_VACUUM = 20.0 # in Angstrom -- from manuscript" |
| 62 | + ], |
| 63 | + "metadata": { |
| 64 | + "collapsed": false |
| 65 | + }, |
| 66 | + "execution_count": null |
| 67 | + }, |
| 68 | + { |
| 69 | + "cell_type": "markdown", |
| 70 | + "source": [ |
| 71 | + "### 1.2. Install Packages\n", |
| 72 | + "The step executes only in Pyodide environment. For other environments, the packages should be installed via `pip install` (see [README](../../README.ipynb))." |
| 73 | + ], |
| 74 | + "metadata": { |
| 75 | + "collapsed": false |
| 76 | + } |
| 77 | + }, |
| 78 | + { |
| 79 | + "cell_type": "code", |
| 80 | + "outputs": [], |
| 81 | + "source": [ |
| 82 | + "import sys\n", |
| 83 | + "\n", |
| 84 | + "if sys.platform == \"emscripten\":\n", |
| 85 | + " import micropip\n", |
| 86 | + "\n", |
| 87 | + " await micropip.install('mat3ra-api-examples', deps=False)\n", |
| 88 | + " from utils.jupyterlite import install_packages\n", |
| 89 | + "\n", |
| 90 | + " await install_packages(\"specific_examples|create_interface_with_min_strain_zsl.ipynb\")" |
| 91 | + ], |
| 92 | + "metadata": { |
| 93 | + "collapsed": false |
| 94 | + }, |
| 95 | + "execution_count": null |
| 96 | + }, |
| 97 | + { |
| 98 | + "cell_type": "markdown", |
| 99 | + "source": [ |
| 100 | + "### 1.3. Get input materials and assign `substrate` and `film`" |
| 101 | + ], |
| 102 | + "metadata": {} |
| 103 | + }, |
| 104 | + { |
| 105 | + "cell_type": "code", |
| 106 | + "outputs": [], |
| 107 | + "source": [ |
| 108 | + "from mat3ra.standata.materials import Materials\n", |
| 109 | + "from mat3ra.made.material import Material\n", |
| 110 | + "\n", |
| 111 | + "film = Material(Materials.get_by_name_first_match(\"Graphene\"))\n", |
| 112 | + "substrate = Material(Materials.get_by_name_first_match(\"SiO2\"))" |
| 113 | + ], |
| 114 | + "metadata": { |
| 115 | + "collapsed": false |
| 116 | + }, |
| 117 | + "execution_count": null |
| 118 | + }, |
| 119 | + { |
| 120 | + "cell_type": "markdown", |
| 121 | + "source": [ |
| 122 | + "### 1.4. Preview Substrate and Film" |
| 123 | + ], |
| 124 | + "metadata": { |
| 125 | + "collapsed": false |
| 126 | + } |
| 127 | + }, |
| 128 | + { |
| 129 | + "cell_type": "code", |
| 130 | + "outputs": [], |
| 131 | + "source": [ |
| 132 | + "from utils.visualize import visualize_materials as visualize\n", |
| 133 | + "\n", |
| 134 | + "visualize([substrate, film], repetitions=[3, 3, 1], rotation=\"0x\")" |
| 135 | + ], |
| 136 | + "metadata": { |
| 137 | + "collapsed": false |
| 138 | + }, |
| 139 | + "execution_count": null |
| 140 | + }, |
| 141 | + { |
| 142 | + "cell_type": "markdown", |
| 143 | + "source": [ |
| 144 | + "## 2. Configure slabs and select termination pair\n", |
| 145 | + "\n", |
| 146 | + "### 2.1. Create Substrate and Layer Slabs\n", |
| 147 | + "Slab Configuration lets define the slab thickness, vacuum, and the Miller indices of the interfacial plane and get the slabs with possible terminations.\n", |
| 148 | + "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." |
| 149 | + ], |
| 150 | + "metadata": {} |
| 151 | + }, |
| 152 | + { |
| 153 | + "cell_type": "code", |
| 154 | + "outputs": [], |
| 155 | + "source": [ |
| 156 | + "from mat3ra.made.tools.build.slab import SlabConfiguration, get_terminations, create_slab, \\\n", |
| 157 | + " PymatgenSlabGeneratorParameters\n", |
| 158 | + "\n", |
| 159 | + "film_slab_configuration = SlabConfiguration(\n", |
| 160 | + " bulk=film,\n", |
| 161 | + " miller_indices=FILM_MILLER_INDICES,\n", |
| 162 | + " thickness=FILM_THICKNESS, # in atomic layers\n", |
| 163 | + " vacuum=FILM_VACUUM, # in angstroms\n", |
| 164 | + " xy_supercell_matrix=FILM_XY_SUPERCELL_MATRIX,\n", |
| 165 | + " use_orthogonal_z=FILM_USE_ORTHOGONAL_Z\n", |
| 166 | + ")\n", |
| 167 | + "\n", |
| 168 | + "substrate_slab_configuration = SlabConfiguration(\n", |
| 169 | + " bulk=substrate,\n", |
| 170 | + " miller_indices=SUBSTRATE_MILLER_INDICES,\n", |
| 171 | + " thickness=SUBSTRATE_THICKNESS, # in atomic layers\n", |
| 172 | + " vacuum=SUBSTRATE_VACUUM, # in angstroms\n", |
| 173 | + " xy_supercell_matrix=SUBSTRATE_XY_SUPERCELL_MATRIX,\n", |
| 174 | + " use_orthogonal_z=SUBSTRATE_USE_ORTHOGONAL_Z,\n", |
| 175 | + ")\n", |
| 176 | + "\n", |
| 177 | + "params = PymatgenSlabGeneratorParameters(\n", |
| 178 | + " symmetrize=False)" |
| 179 | + ], |
| 180 | + "metadata": {}, |
| 181 | + "execution_count": null |
| 182 | + }, |
| 183 | + { |
| 184 | + "cell_type": "markdown", |
| 185 | + "source": [ |
| 186 | + "### 2.2. Get possible terminations for the slabs" |
| 187 | + ], |
| 188 | + "metadata": { |
| 189 | + "collapsed": false |
| 190 | + } |
| 191 | + }, |
| 192 | + { |
| 193 | + "cell_type": "code", |
| 194 | + "outputs": [], |
| 195 | + "source": [ |
| 196 | + "film_slab_terminations = get_terminations(film_slab_configuration, params)\n", |
| 197 | + "substrate_slab_terminations = get_terminations(substrate_slab_configuration, params)" |
| 198 | + ], |
| 199 | + "metadata": { |
| 200 | + "collapsed": false |
| 201 | + }, |
| 202 | + "execution_count": null |
| 203 | + }, |
| 204 | + { |
| 205 | + "cell_type": "markdown", |
| 206 | + "source": [ |
| 207 | + "### 2.3. Visualize slabs for all possible terminations" |
| 208 | + ], |
| 209 | + "metadata": { |
| 210 | + "collapsed": false |
| 211 | + } |
| 212 | + }, |
| 213 | + { |
| 214 | + "cell_type": "code", |
| 215 | + "outputs": [], |
| 216 | + "source": [ |
| 217 | + "film_slabs = [create_slab(film_slab_configuration, termination) for termination in film_slab_terminations]\n", |
| 218 | + "substrate_slabs = [create_slab(substrate_slab_configuration, termination, params) for termination in\n", |
| 219 | + " substrate_slab_terminations]\n", |
| 220 | + "\n", |
| 221 | + "visualize([{\"material\": slab, \"title\": slab.metadata[\"build\"][\"termination\"]} for slab in film_slabs],\n", |
| 222 | + " repetitions=[3, 3, 1], rotation=\"-90x\")\n", |
| 223 | + "visualize([{\"material\": slab, \"title\": slab.metadata[\"build\"][\"termination\"]} for slab in substrate_slabs],\n", |
| 224 | + " repetitions=[3, 3, 1], rotation=\"-90x\")" |
| 225 | + ], |
| 226 | + "metadata": { |
| 227 | + "collapsed": false |
| 228 | + }, |
| 229 | + "execution_count": null |
| 230 | + }, |
| 231 | + { |
| 232 | + "cell_type": "markdown", |
| 233 | + "source": [ |
| 234 | + "### 2.4. Print terminations for the interface" |
| 235 | + ], |
| 236 | + "metadata": { |
| 237 | + "collapsed": false |
| 238 | + } |
| 239 | + }, |
| 240 | + { |
| 241 | + "cell_type": "code", |
| 242 | + "outputs": [], |
| 243 | + "source": [ |
| 244 | + "from itertools import product\n", |
| 245 | + "\n", |
| 246 | + "termination_pairs = list(product(film_slab_terminations, substrate_slab_terminations))\n", |
| 247 | + "print(\"Termination Pairs (Film, Substrate)\")\n", |
| 248 | + "for idx, termination_pair in enumerate(termination_pairs):\n", |
| 249 | + " print(f\" {idx}: {termination_pair}\")" |
| 250 | + ], |
| 251 | + "metadata": { |
| 252 | + "collapsed": false |
| 253 | + }, |
| 254 | + "execution_count": null |
| 255 | + }, |
| 256 | + { |
| 257 | + "cell_type": "markdown", |
| 258 | + "source": [ |
| 259 | + "## 3. Create interfaces\n", |
| 260 | + "\n", |
| 261 | + "### 3.1. Initialize the Interface Configuration" |
| 262 | + ], |
| 263 | + "metadata": { |
| 264 | + "collapsed": false |
| 265 | + } |
| 266 | + }, |
| 267 | + { |
| 268 | + "cell_type": "code", |
| 269 | + "outputs": [], |
| 270 | + "source": [ |
| 271 | + "from mat3ra.made.tools.build.interface import InterfaceConfiguration\n", |
| 272 | + "from mat3ra.made.tools.build.interface import ZSLStrainMatchingParameters\n", |
| 273 | + "from mat3ra.made.tools.build.interface import ZSLStrainMatchingInterfaceBuilder, \\\n", |
| 274 | + " ZSLStrainMatchingInterfaceBuilderParameters\n", |
| 275 | + "\n", |
| 276 | + "interfaces = []\n", |
| 277 | + "for termination_pair_idx in TERMINATION_PAIR_INDICES:\n", |
| 278 | + " termination_pair = termination_pairs[termination_pair_idx]\n", |
| 279 | + " film_termination, substrate_termination = termination_pair\n", |
| 280 | + " interface_configuration = InterfaceConfiguration(\n", |
| 281 | + " film_configuration=film_slab_configuration,\n", |
| 282 | + " substrate_configuration=substrate_slab_configuration,\n", |
| 283 | + " film_termination=film_termination,\n", |
| 284 | + " substrate_termination=substrate_termination,\n", |
| 285 | + " distance_z=INTERFACE_DISTANCE,\n", |
| 286 | + " vacuum=INTERFACE_VACUUM\n", |
| 287 | + " )\n", |
| 288 | + "\n", |
| 289 | + " zsl_strain_matching_parameters = ZSLStrainMatchingParameters(\n", |
| 290 | + " max_area=MAX_AREA,\n", |
| 291 | + " )\n", |
| 292 | + "\n", |
| 293 | + " matched_interfaces_builder = ZSLStrainMatchingInterfaceBuilder(\n", |
| 294 | + " build_parameters=ZSLStrainMatchingInterfaceBuilderParameters(\n", |
| 295 | + " strain_matching_parameters=zsl_strain_matching_parameters))\n", |
| 296 | + " interfaces_sorted_by_size_and_strain = matched_interfaces_builder.get_materials(\n", |
| 297 | + " configuration=interface_configuration)\n", |
| 298 | + " selected_interface = interfaces_sorted_by_size_and_strain[0]\n", |
| 299 | + " selected_interface.name = f\"Interface {termination_pair}\"\n", |
| 300 | + " interfaces.append(selected_interface)\n" |
| 301 | + ], |
| 302 | + "metadata": { |
| 303 | + "collapsed": false |
| 304 | + }, |
| 305 | + "execution_count": null |
| 306 | + }, |
| 307 | + { |
| 308 | + "cell_type": "markdown", |
| 309 | + "source": [ |
| 310 | + "## 4. Visualize the interfaces" |
| 311 | + ], |
| 312 | + "metadata": { |
| 313 | + "collapsed": false |
| 314 | + } |
| 315 | + }, |
| 316 | + { |
| 317 | + "cell_type": "code", |
| 318 | + "outputs": [], |
| 319 | + "source": [ |
| 320 | + "visualize(interfaces, repetitions=[3, 3, 1])\n", |
| 321 | + "visualize(interfaces, repetitions=[1, 1, 1], rotation=\"-90x\")" |
| 322 | + ], |
| 323 | + "metadata": { |
| 324 | + "collapsed": false |
| 325 | + }, |
| 326 | + "execution_count": null |
| 327 | + }, |
| 328 | + { |
| 329 | + "cell_type": "markdown", |
| 330 | + "metadata": {}, |
| 331 | + "source": [ |
| 332 | + "## 5. Pass data to the outside runtime" |
| 333 | + ] |
| 334 | + }, |
| 335 | + { |
| 336 | + "cell_type": "code", |
| 337 | + "execution_count": null, |
| 338 | + "metadata": {}, |
| 339 | + "outputs": [], |
| 340 | + "source": [ |
| 341 | + "from utils.jupyterlite import download_content_to_file\n", |
| 342 | + "\n", |
| 343 | + "for idx, interface in enumerate(interfaces):\n", |
| 344 | + " download_content_to_file(interfaces, f\"interface_{idx}.json\")" |
| 345 | + ] |
| 346 | + } |
| 347 | + ], |
| 348 | + "metadata": { |
| 349 | + "kernelspec": { |
| 350 | + "display_name": ".venv", |
| 351 | + "language": "python", |
| 352 | + "name": "python3" |
| 353 | + }, |
| 354 | + "language_info": { |
| 355 | + "codemirror_mode": { |
| 356 | + "name": "ipython", |
| 357 | + "version": 3 |
| 358 | + }, |
| 359 | + "file_extension": ".py", |
| 360 | + "mimetype": "text/x-python", |
| 361 | + "name": "python", |
| 362 | + "nbconvert_exporter": "python", |
| 363 | + "pygments_lexer": "ipython3", |
| 364 | + "version": "3.10.12" |
| 365 | + }, |
| 366 | + "widgets": { |
| 367 | + "application/vnd.jupyter.widget-state+json": { |
| 368 | + "state": {}, |
| 369 | + "version_major": 2, |
| 370 | + "version_minor": 0 |
| 371 | + } |
| 372 | + } |
| 373 | + }, |
| 374 | + "nbformat": 4, |
| 375 | + "nbformat_minor": 4 |
| 376 | +} |
0 commit comments