Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,278 @@
{
Copy link
Member

@timurbazhirov timurbazhirov Dec 19, 2024

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

"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",
" ![FIG. 2.](https://i.imgur.com/W3dPmWK.png)\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
}
Loading