-
Notifications
You must be signed in to change notification settings - Fork 5
feature/SOF-7521 feature: slab tutorial #176
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
a7a7ac2
update: add slab tutorial nb
VsevolodX 96e84dc
feat: add slab tutorial
VsevolodX b3961e2
update: use standata
VsevolodX 7046db0
chore: cleanup
VsevolodX 81f10c7
chore: cleanup
VsevolodX 0d44530
chore: adjsut wording
VsevolodX File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
278 changes: 278 additions & 0 deletions
278
other/materials_designer/specific_examples/slab_strontium_titanate.ipynb
This file contains hidden or 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,278 @@ | ||
| { | ||
| "cells": [ | ||
| { | ||
| "cell_type": "markdown", | ||
| "source": [ | ||
| "# Slabs of SrTiO3(011) with specified terminations\n", | ||
| "\n", | ||
| "## 0. Introduction\n", | ||
| "\n", | ||
| "This notebook demonstrates how to create slabs of SrTiO3(011) with specified terminations following the manuscript:\n", | ||
| "\n", | ||
| "> **R. I. Eglitis and David Vanderbilt**\n", | ||
| "> *First-principles calculations of atomic and electronic structure of SrTiO3 (001) and (011) surfaces*\n", | ||
| "> Phys. Rev. B 77, 195408 (2008)\n", | ||
| "> [DOI: 10.1103/PhysRevB.77.195408](https://doi.org/10.1103/PhysRevB.77.195408)\n", | ||
| "\n", | ||
| "Replicating the material from the FIG. 2. with 2 different terminations:\n", | ||
| "\n", | ||
| " \n", | ||
| "\n" | ||
| ], | ||
| "metadata": { | ||
| "collapsed": false | ||
| }, | ||
| "id": "95a274d80df28ccd" | ||
| }, | ||
| { | ||
| "cell_type": "markdown", | ||
| "source": [ | ||
| "## 1. Prepare the Environment\n", | ||
| "### 1.1. Set up defect parameters " | ||
| ], | ||
| "metadata": { | ||
| "collapsed": false | ||
| }, | ||
| "id": "d55eaee8bc55bffd" | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "outputs": [], | ||
| "source": [ | ||
| "MILLER_INDICES = (0, 1, 1)\n", | ||
| "THICKNESS = 3 # in atomic layers\n", | ||
| "VACUUM = 10.0 # in angstroms\n", | ||
| "XY_SUPERCELL_MATRIX = [[1, 0], [0, 1]]\n", | ||
| "USE_ORTHOGONAL_Z = True\n", | ||
| "USE_CONVENTIONAL_CELL = True\n" | ||
| ], | ||
| "metadata": { | ||
| "collapsed": false | ||
| }, | ||
| "id": "4b64735060047bec", | ||
| "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": "5e0ce05f6f031b3f" | ||
| }, | ||
| { | ||
| "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(\"\")" | ||
| ], | ||
| "metadata": { | ||
| "collapsed": false | ||
| }, | ||
| "id": "b457673560550933", | ||
| "execution_count": null | ||
| }, | ||
| { | ||
| "cell_type": "markdown", | ||
| "source": [ | ||
| "### 1.3. Get input materials" | ||
| ], | ||
| "metadata": { | ||
| "collapsed": false | ||
| }, | ||
| "id": "1659a8e9afe434fb" | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "outputs": [], | ||
| "source": [ | ||
| "from mat3ra.made.material import Material\n", | ||
| "from mat3ra.standata.materials import Materials\n", | ||
| "from mat3ra.made.tools.modify import rotate\n", | ||
| "\n", | ||
| "material = Material(Materials.get_by_name_first_match(\"SrTiO3\"))\n", | ||
| "# Rotate material to correctly identify multiple terminations.\n", | ||
| "# Without the rotation, the current implementation only finds a single termination (as of 2024-12).\n", | ||
| "material = rotate(material, axis=[1, 0, 0], angle=10)" | ||
| ], | ||
| "metadata": { | ||
| "collapsed": false | ||
| }, | ||
| "id": "b588ccfe51967a86", | ||
| "execution_count": null | ||
| }, | ||
| { | ||
| "cell_type": "markdown", | ||
| "source": [ | ||
| "### 1.4. Preview the material" | ||
| ], | ||
| "metadata": { | ||
| "collapsed": false | ||
| }, | ||
| "id": "8c13970a869adfa9" | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "outputs": [], | ||
| "source": [ | ||
| "from utils.visualize import visualize_materials as visualize\n", | ||
| "\n", | ||
| "visualize(material, repetitions=[3, 3, 3], rotation=\"0x\")\n", | ||
| "visualize(material, repetitions=[3, 3, 3], rotation=\"-90x\")" | ||
| ], | ||
| "metadata": { | ||
| "collapsed": false | ||
| }, | ||
| "id": "c4f6e2697f97965f", | ||
| "execution_count": null | ||
| }, | ||
| { | ||
| "cell_type": "markdown", | ||
| "source": [ | ||
| "## 2. Configure slab\n", | ||
| "\n", | ||
| "### 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": "6634dae92a6c07b9" | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "outputs": [], | ||
| "source": [ | ||
| "\n", | ||
| "from mat3ra.made.tools.build.slab import SlabConfiguration\n", | ||
| "\n", | ||
| "slab_configuration = SlabConfiguration(\n", | ||
| " bulk=material,\n", | ||
| " miller_indices=MILLER_INDICES,\n", | ||
| " thickness=THICKNESS, # in atomic layers\n", | ||
| " vacuum=VACUUM, # in angstroms\n", | ||
| " xy_supercell_matrix=XY_SUPERCELL_MATRIX,\n", | ||
| " use_orthogonal_z=USE_ORTHOGONAL_Z,\n", | ||
| " use_conventional_cell=USE_CONVENTIONAL_CELL,\n", | ||
| ")" | ||
| ], | ||
| "metadata": { | ||
| "collapsed": false | ||
| }, | ||
| "id": "3ad6765249610aa4", | ||
| "execution_count": null | ||
| }, | ||
| { | ||
| "cell_type": "markdown", | ||
| "source": [ | ||
| "### 2.2. Get possible terminations for the slabs" | ||
| ], | ||
| "metadata": { | ||
| "collapsed": false | ||
| }, | ||
| "id": "afb4c9bb89c8690b" | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "outputs": [], | ||
| "source": [ | ||
| "from mat3ra.made.tools.build.slab import get_terminations\n", | ||
| "\n", | ||
| "slab_terminations = get_terminations(slab_configuration)\n", | ||
| "print(\"Terminations\")\n", | ||
| "for idx, termination in enumerate(slab_terminations):\n", | ||
| " print(f\" {idx}: {termination}\")" | ||
| ], | ||
| "metadata": { | ||
| "collapsed": false | ||
| }, | ||
| "id": "70bec9d69d58b28a", | ||
| "execution_count": null | ||
| }, | ||
| { | ||
| "cell_type": "markdown", | ||
| "source": [ | ||
| "## 3. Visualize slabs for all possible terminations" | ||
| ], | ||
| "metadata": { | ||
| "collapsed": false | ||
| }, | ||
| "id": "c6e2e18452972b21" | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "outputs": [], | ||
| "source": [ | ||
| "from mat3ra.made.tools.build.slab import create_slab\n", | ||
| "\n", | ||
| "slabs = [create_slab(slab_configuration, termination) for termination in slab_terminations]\n", | ||
| "\n", | ||
| "visualize([{\"material\": slab, \"title\": slab.metadata[\"build\"][\"termination\"]} for slab in slabs], repetitions=[3, 3, 1])\n", | ||
| "visualize([{\"material\": slab, \"title\": slab.metadata[\"build\"][\"termination\"]} for slab in slabs], repetitions=[3, 3, 1],\n", | ||
| " rotation=\"-90x\")" | ||
| ], | ||
| "metadata": { | ||
| "collapsed": false | ||
| }, | ||
| "id": "246cb1f0437dbde0", | ||
| "execution_count": null | ||
| }, | ||
| { | ||
| "cell_type": "markdown", | ||
| "source": [ | ||
| "## 4. Download materials" | ||
| ], | ||
| "metadata": { | ||
| "collapsed": false | ||
| }, | ||
| "id": "d667623ad5f2e061" | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "outputs": [], | ||
| "source": [ | ||
| "from utils.jupyterlite import download_content_to_file\n", | ||
| "\n", | ||
| "for slab in slabs:\n", | ||
| " download_content_to_file(slab, f\"{slab.name}.json\")" | ||
| ], | ||
| "metadata": { | ||
| "collapsed": false | ||
| }, | ||
| "id": "3705115f04ac0010", | ||
| "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 | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment is cryptic, let's instead put:
Rotate material to correctly identify multiple terminations. Without the rotation, the current implementation only finds a single termination (as of 2024-12).Reply via ReviewNB