diff --git a/other/materials_designer/create_interface_with_min_strain_zsl.ipynb b/other/materials_designer/create_interface_with_min_strain_zsl.ipynb index 0b290348..a4f4b1de 100644 --- a/other/materials_designer/create_interface_with_min_strain_zsl.ipynb +++ b/other/materials_designer/create_interface_with_min_strain_zsl.ipynb @@ -52,21 +52,25 @@ "IS_TERMINATIONS_SELECTION_INTERACTIVE = False \n", "\n", "FILM_INDEX = 1 # Index in the list of materials, to access as materials[FILM_INDEX]\n", - "FILM_MILLER_INDICES = (0, 0, 1)\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 = (1, 1, 1)\n", + "SUBSTRATE_MILLER_INDICES = (0,0,1)\n", "SUBSTRATE_THICKNESS = 3 # in atomic layers\n", - "SUBSTRATE_VACUUM = 3.0 # in angstroms\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 = 50 # in Angstrom^2\n", + "# Additional fine-tuning parameters (increase values to get more strained matches):\n", + "MAX_AREA_TOLERANCE = 0.09 # in Angstrom^2\n", + "MAX_ANGLE_TOLERANCE = 0.03\n", + "MAX_LENGTH_TOLERANCE = 0.03\n", "# Set the termination pair indices\n", "TERMINATION_PAIR_INDEX = 0 # Will be overridden in interactive selection is used\n", "INTERFACE_DISTANCE = 3.0 # in Angstrom\n", @@ -338,7 +342,10 @@ "source": [ "from mat3ra.made.tools.build.interface import ZSLStrainMatchingParameters\n", "zsl_strain_matching_parameters = ZSLStrainMatchingParameters(\n", - " max_area=MAX_AREA\n", + " max_area=MAX_AREA,\n", + " max_area_tol=MAX_AREA_TOLERANCE,\n", + " max_angle_tol=MAX_ANGLE_TOLERANCE,\n", + " max_length_tol=MAX_LENGTH_TOLERANCE,\n", ")" ], "metadata": { diff --git a/other/materials_designer/create_interface_with_no_strain_matching.ipynb b/other/materials_designer/create_interface_with_no_strain_matching.ipynb index 8d726c28..ca5085a9 100644 --- a/other/materials_designer/create_interface_with_no_strain_matching.ipynb +++ b/other/materials_designer/create_interface_with_no_strain_matching.ipynb @@ -44,6 +44,7 @@ "IS_TERMINATIONS_SELECTION_INTERACTIVE = False \n", "# Enable scaling of the film slab atomic coordinates to match the substrate lattice (preserve coordinates in crystal units).\n", "ENABLE_FILM_SCALING = True\n", + "CREATE_SLABS = True\n", "\n", "FILM_INDEX = 1\n", "FILM_MILLER_INDICES = (0, 0, 1)\n", @@ -314,9 +315,7 @@ " substrate_termination=substrate_termination,\n", " interface_distance=INTERFACE_DISTANCE, # in Angstrom\n", " interface_vacuum=INTERFACE_VACUUM # in Angstrom\n", - ")\n", - "\n", - "interface = create_interface(interface_configuration)" + ")" ] }, { @@ -333,9 +332,9 @@ "outputs": [], "source": [ "from mat3ra.made.tools.build.interface import SimpleInterfaceBuilder, SimpleInterfaceBuilderParameters\n", - "if ENABLE_FILM_SCALING:\n", - " builder = SimpleInterfaceBuilder(build_parameters=SimpleInterfaceBuilderParameters(scale_film=True))\n", - " interface = builder.get_material(configuration=interface_configuration)" + "\n", + "builder = SimpleInterfaceBuilder(build_parameters=SimpleInterfaceBuilderParameters(scale_film=ENABLE_FILM_SCALING, create_slabs=CREATE_SLABS))\n", + "interface = builder.get_material(configuration=interface_configuration)" ], "metadata": { "collapsed": false diff --git a/other/materials_designer/specific_examples/heterostructure_example_5_stack.ipynb b/other/materials_designer/specific_examples/heterostructure_example_5_stack.ipynb new file mode 100644 index 00000000..8c9d8592 --- /dev/null +++ b/other/materials_designer/specific_examples/heterostructure_example_5_stack.ipynb @@ -0,0 +1,698 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "source": [ + "# Create an example Stack of TiN/NbSe2/HfO2 with defects \n", + "\n", + "This notebook demonstrates how to create a non-polar heterostructure stack of three materials: TiN, NbSe2, and HfO2. The stack is created by sequentially adding interfaces between the materials. The interfaces are created using the Zero Strain Layer (ZSL) method, which ensures that the materials are strain-matched at the interface. \n", + "O-substitution defects are added \n", + "\n", + "\n", + "

Usage

\n", + "\n", + "1. **Set up the notebook and install packages**\n", + "2. **Import materials from Standata**\n", + "3. **Select and preview materials for the heterostructure**\n", + "4. **Build the heterostructure layer by layer with ZSL interface builder**\n", + "\n", + "## Summary\n", + "\n", + "1. **Prepare the Environment:** Set up the notebook and install packages, preview the input materials.\n", + "2. **Create Interfaces:** Sequentially create interfaces between the materials.\n", + "3. **Visualize:** Preview the materials and resulting interfaces.\n", + "4. **Pass to Runtime:** Pass the final heterostructure to the external runtime.\n", + "\n", + "## Notes\n", + "\n", + "1. For more information, see [Introduction](Introduction.ipynb)\n", + "\n", + "\n" + ], + "metadata": { + "collapsed": false + }, + "id": "ad0a4601cb4095ad" + }, + { + "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.\n" + ], + "metadata": { + "collapsed": false + }, + "id": "a0b4736f3dffa189" + }, + { + "cell_type": "code", + "outputs": [], + "source": [ + "# Interface parameters\n", + "MAX_AREA_01 = 100 # search area for the first interface\n", + "INTERFACE_01_INDEX = 1 # index of the selected interface\n", + "\n", + "MAX_AREA_12 = 150 # search area for the second interface\n", + "INTERFACE_12_INDEX = 0 # index of the selected interface\n", + "\n", + "INTERFACE_01_DISTANCE = 6.0 # in Angstrom\n", + "FIRST_INTERFACE_VACUUM = 6.0 # in Angstrom\n", + "INTERFACE_12_DISTANCE = 6.0 # in Angstrom\n", + "SECOND_INTERFACE_VACUUM = 50.0 # in Angstrom\n", + "\n", + "# Configuration for Material 0 (Substrate)\n", + "MATERIAL_0_MILLER_INDICES = (1, 0,0)\n", + "MATERIAL_0_THICKNESS = 3 # in atomic layers\n", + "MATERIAL_0_VACUUM = 10.0 # in Angstroms\n", + "MATERIAL_0_XY_SUPERCELL_MATRIX = [[1, 0], [0, 1]]\n", + "MATERIAL_0_USE_ORTHOGONAL_Z = True\n", + "\n", + "# Configuration for Material 1 (Film 1)\n", + "MATERIAL_1_MILLER_INDICES = (0,0,1)\n", + "MATERIAL_1_THICKNESS = 1 # in atomic layers\n", + "MATERIAL_1_VACUUM = 10.0 # in Angstroms\n", + "MATERIAL_1_XY_SUPERCELL_MATRIX = [[1, 0], [0, 1]]\n", + "MATERIAL_1_USE_ORTHOGONAL_Z = True\n", + "\n", + "# Configuration for Material 2 (Film 2)\n", + "MATERIAL_2_MILLER_INDICES = (0,0,1)\n", + "MATERIAL_2_THICKNESS = 2 # in atomic layers\n", + "MATERIAL_2_VACUUM = 10.0 # in Angstroms\n", + "MATERIAL_2_XY_SUPERCELL_MATRIX = [[1, 0], [0, 1]]\n", + "MATERIAL_2_USE_ORTHOGONAL_Z = True\n", + "\n", + "# Set termination pair indices for both interfaces\n", + "TERMINATION_PAIR_INDEX_01 = 0\n", + "TERMINATION_PAIR_INDEX_12 = 0\n" + ], + "metadata": { + "collapsed": false + }, + "id": "9e90252bcef065c9", + "execution_count": null + }, + { + "cell_type": "markdown", + "source": [ + "### 1.2. Install Packages\n", + "\n", + "The step executes only in Pyodide environment. For other environments, the packages should be installed via `pip install` (see [README](../../README.ipynb)).\n" + ], + "metadata": { + "collapsed": false + }, + "id": "e460756f40327e78" + }, + { + "cell_type": "code", + "outputs": [], + "source": [ + "import sys\n", + "\n", + "if sys.platform == \"emscripten\":\n", + " import micropip\n", + " await micropip.install('mat3ra-api-examples', deps=False)\n", + " from utils.jupyterlite import install_packages\n", + " await install_packages(\"create_interface_with_min_strain_zsl.ipynb\")\n" + ], + "metadata": { + "collapsed": false + }, + "id": "a4d99b5b40274810", + "execution_count": null + }, + { + "cell_type": "markdown", + "source": [ + "### 1.3. Get Input Materials and Assign `material0`, `material1`, and `material2`\n", + "\n", + "Materials are loaded with `get_materials()`. The first material is assigned as **Material 0**, the second as **Material 1**, and the third as **Material 2**.\n" + ], + "metadata": { + "collapsed": false + }, + "id": "c4b29abaa6160a66" + }, + { + "cell_type": "code", + "outputs": [], + "source": [ + "from mat3ra.standata.materials import Materials\n", + "from mat3ra.made.material import Material\n", + "names = [\"TiN\", \"NbS2\", \"HfO2.*ORC\"]\n", + "materials = []\n", + "for name in names:\n", + " material = Material(Materials.get_by_name_first_match(name))\n", + " materials.append(material)\n", + " \n", + "material0 = materials[0]\n", + "material1 = materials[1]\n", + "material2 = materials[2]\n", + " " + ], + "metadata": { + "collapsed": false + }, + "id": "3975b2f204b91dd7", + "execution_count": null + }, + { + "cell_type": "markdown", + "source": [ + "### 1.4. Preview Original Materials\n", + "\n", + "Visualize the three original materials.\n" + ], + "metadata": { + "collapsed": false + }, + "id": "1ffc1f88eedbc9a4" + }, + { + "cell_type": "code", + "outputs": [], + "source": [ + "from utils.visualize import visualize_materials as visualize\n", + "\n", + "visualize([material0, material1, material2], repetitions=[3, 3, 1], rotation=\"0x\")\n" + ], + "metadata": { + "collapsed": false + }, + "id": "6253034909a0fef9", + "execution_count": null + }, + { + "cell_type": "markdown", + "source": [ + "## 2. Create First Interface (Material 0 + Material 1)\n", + "\n", + "### 2.1. Configure Slabs and Select Termination Pair\n", + "\n", + "Set up slab configurations for **Material 0** and **Material 1**, then select terminations for the first interface.\n" + ], + "metadata": { + "collapsed": false + }, + "id": "574327eaccdd52f0" + }, + { + "cell_type": "code", + "outputs": [], + "source": [ + "from mat3ra.made.tools.build.slab import SlabConfiguration, get_terminations, create_slab, \\\n", + " PymatgenSlabGeneratorParameters\n", + "from mat3ra.made.tools.modify import translate_to_z_level\n", + "\n", + "# Slab Configuration for Material 1\n", + "material1_slab_configuration = SlabConfiguration(\n", + " bulk=material1,\n", + " miller_indices=MATERIAL_1_MILLER_INDICES,\n", + " thickness=MATERIAL_1_THICKNESS, # in atomic layers\n", + " vacuum=MATERIAL_1_VACUUM, # in Angstroms\n", + " xy_supercell_matrix=MATERIAL_1_XY_SUPERCELL_MATRIX,\n", + " use_orthogonal_z=MATERIAL_1_USE_ORTHOGONAL_Z\n", + ")\n", + "\n", + "# Slab Configuration for Material 0 (Substrate)\n", + "material0_slab_configuration = SlabConfiguration(\n", + " bulk=material0,\n", + " miller_indices=MATERIAL_0_MILLER_INDICES,\n", + " thickness=MATERIAL_0_THICKNESS, # in atomic layers\n", + " vacuum=MATERIAL_0_VACUUM, # in Angstroms\n", + " xy_supercell_matrix=MATERIAL_0_XY_SUPERCELL_MATRIX,\n", + " use_orthogonal_z=MATERIAL_0_USE_ORTHOGONAL_Z\n", + ")\n", + "\n", + "params = PymatgenSlabGeneratorParameters(symmetrize=False)\n", + "# Get possible terminations for the slabs\n", + "material1_slab_terminations = get_terminations(material1_slab_configuration, build_parameters=params)\n", + "material0_slab_terminations = get_terminations(material0_slab_configuration, build_parameters=params)\n", + "\n", + "# Visualize all possible terminations\n", + "material1_slabs = [create_slab(material1_slab_configuration, termination, build_parameters=params) for termination in material1_slab_terminations]\n", + "material0_slabs = [create_slab(material0_slab_configuration, termination, build_parameters=params) for termination in material0_slab_terminations]\n", + "\n", + "visualize(\n", + " [{\"material\": slab, \"title\": slab.metadata[\"build\"][\"termination\"]} for slab in material1_slabs],\n", + " repetitions=[3, 3, 1],\n", + " rotation=\"-90x\"\n", + ")\n", + "\n", + "visualize(\n", + " [{\"material\": slab, \"title\": slab.metadata[\"build\"][\"termination\"]} for slab in material0_slabs],\n", + " repetitions=[3, 3, 1],\n", + " rotation=\"-90x\"\n", + ")\n" + ], + "metadata": { + "collapsed": false + }, + "id": "de4fe773ee9c8a61", + "execution_count": null + }, + { + "cell_type": "markdown", + "source": [ + "### 2.2. Print and Select Termination Pair for First Interface\n" + ], + "metadata": { + "collapsed": false + }, + "id": "e4aea26afab84e0c" + }, + { + "cell_type": "code", + "outputs": [], + "source": [ + "from itertools import product\n", + "\n", + "termination_pairs_01 = list(product(material1_slab_terminations, material0_slab_terminations)) \n", + "print(\"Termination Pairs for First Interface (Material1, Material0)\")\n", + "for idx, termination_pair in enumerate(termination_pairs_01):\n", + " print(f\" {idx}: {termination_pair}\")\n" + ], + "metadata": { + "collapsed": false + }, + "id": "4e467693b61f0125", + "execution_count": null + }, + { + "cell_type": "markdown", + "source": [ + "### 2.4. Initialize Interface Configuration for First Interface\n" + ], + "metadata": { + "collapsed": false + }, + "id": "7621d2178a91c691" + }, + { + "cell_type": "code", + "outputs": [], + "source": [ + "from mat3ra.made.tools.build.interface import InterfaceConfiguration\n", + "\n", + "material1_termination, material0_termination = termination_pairs_01[TERMINATION_PAIR_INDEX_01]\n", + "interface_configuration_01 = InterfaceConfiguration(\n", + " film_configuration=material1_slab_configuration,\n", + " substrate_configuration=material0_slab_configuration,\n", + " film_termination=material1_termination,\n", + " substrate_termination=material0_termination,\n", + " distance_z=INTERFACE_01_DISTANCE,\n", + " vacuum=FIRST_INTERFACE_VACUUM\n", + ")\n" + ], + "metadata": { + "collapsed": false + }, + "id": "9e87ca9779cee593", + "execution_count": null + }, + { + "cell_type": "markdown", + "source": [ + "### 2.5. Set Strain Matching Parameters and Generate First Interface\n" + ], + "metadata": { + "collapsed": false + }, + "id": "afab24f1d8cf9ad7" + }, + { + "cell_type": "code", + "outputs": [], + "source": [ + "from mat3ra.made.tools.build.interface import ZSLStrainMatchingParameters\n", + "from mat3ra.made.tools.build.interface import ZSLStrainMatchingInterfaceBuilder, ZSLStrainMatchingInterfaceBuilderParameters\n", + "\n", + "zsl_strain_matching_parameters_01 = ZSLStrainMatchingParameters(\n", + " max_area=MAX_AREA_01,\n", + " max_area_ratio_tol=0.2,\n", + " max_angle_tol=0.1,\n", + " max_length_tol=0.1,\n", + ")\n", + "\n", + "matched_interfaces_builder_01 = ZSLStrainMatchingInterfaceBuilder(\n", + " build_parameters=ZSLStrainMatchingInterfaceBuilderParameters(\n", + " strain_matching_parameters=zsl_strain_matching_parameters_01\n", + " )\n", + ")\n", + "\n", + "interfaces_01_sorted = matched_interfaces_builder_01.get_materials(configuration=interface_configuration_01)\n" + ], + "metadata": { + "collapsed": false + }, + "id": "9b72198198a18278", + "execution_count": null + }, + { + "cell_type": "markdown", + "source": [ + "### 2.6. Plot and Select First Interface\n" + ], + "metadata": { + "collapsed": false + }, + "id": "4989c48b4ed6a33d" + }, + { + "cell_type": "code", + "outputs": [], + "source": [ + "from utils.plot import plot_strain_vs_atoms\n", + "\n", + "PLOT_SETTINGS = {\n", + " \"HEIGHT\": 600,\n", + " \"X_SCALE\": \"log\", # or linear\n", + " \"Y_SCALE\": \"log\", # or linear\n", + "}\n", + "\n", + "plot_strain_vs_atoms(interfaces_01_sorted, PLOT_SETTINGS)" + ], + "metadata": { + "collapsed": false + }, + "id": "32e05e63fea1b5a3", + "execution_count": null + }, + { + "cell_type": "markdown", + "source": [ + "### 2.7. Preview the First Interface\n" + ], + "metadata": { + "collapsed": false + }, + "id": "342d6261ae79122" + }, + { + "cell_type": "code", + "outputs": [], + "source": [ + "selected_interface_01 = interfaces_01_sorted[INTERFACE_01_INDEX]\n", + "# selected_interface_01 = translate_to_z_level(selected_interface_01, \"bottom\")\n", + "\n", + "visualize(selected_interface_01, repetitions=[1, 1, 1])\n", + "visualize(selected_interface_01, repetitions=[1, 1, 1], rotation=\"-90x\")" + ], + "metadata": { + "collapsed": false + }, + "id": "1148759314be11cc", + "execution_count": null + }, + { + "cell_type": "markdown", + "source": [ + "??## 3. Create Second Interface (First Interface + Material 2)\n", + "\n", + "### 3.1. Configure Slabs and Select Termination Pair for Second Interface\n", + "\n", + "Now, use the first interface as the substrate to add **Material 2**.\n" + ], + "metadata": { + "collapsed": false + }, + "id": "df770aba2dbc2df0" + }, + { + "cell_type": "code", + "outputs": [], + "source": [ + "\n", + "\n", + "from mat3ra.made.tools.build.slab import SlabConfiguration, get_terminations, create_slab\n", + "\n", + "# Slab Configuration for Material 2\n", + "material2_slab_configuration = SlabConfiguration(\n", + " bulk=material2,\n", + " miller_indices=MATERIAL_2_MILLER_INDICES,\n", + " thickness=MATERIAL_2_THICKNESS, # in atomic layers\n", + " vacuum=MATERIAL_2_VACUUM, # in atomic layers\n", + " xy_supercell_matrix=MATERIAL_2_XY_SUPERCELL_MATRIX,\n", + " use_orthogonal_z=MATERIAL_2_USE_ORTHOGONAL_Z\n", + ")\n", + "\n", + "# Slab Configuration for Substrate (First Interface)\n", + "substrate_second_slab_configuration = SlabConfiguration(\n", + " bulk=selected_interface_01,\n", + " miller_indices=(0, 0, 1), # Z-orientation for the first interface\n", + " thickness=1, # One unit cell thick\n", + " vacuum=FIRST_INTERFACE_VACUUM, \n", + " xy_supercell_matrix=MATERIAL_0_XY_SUPERCELL_MATRIX, # Adjust if necessary\n", + " use_orthogonal_z=MATERIAL_0_USE_ORTHOGONAL_Z\n", + ")\n", + "\n", + "# Get possible terminations for the second interface slabs\n", + "material2_slab_terminations = get_terminations(material2_slab_configuration, build_parameters=params)\n", + "substrate_second_slab_terminations = get_terminations(substrate_second_slab_configuration, build_parameters=params)\n", + "\n", + "# Visualize all possible terminations for Material 2 and Substrate (First Interface)\n", + "material2_slabs = [create_slab(material2_slab_configuration, termination, build_parameters=params) for termination in material2_slab_terminations]\n", + "substrate_second_slabs = [create_slab(substrate_second_slab_configuration, termination, build_parameters=params) for termination in substrate_second_slab_terminations]\n" + ], + "metadata": { + "collapsed": false + }, + "id": "636e0e4c45b02925", + "execution_count": null + }, + { + "cell_type": "markdown", + "source": [ + "### 3.2. Print and Select Termination Pair for Second Interface\n" + ], + "metadata": { + "collapsed": false + }, + "id": "ac68ed5b9219b0dc" + }, + { + "cell_type": "code", + "outputs": [], + "source": [ + "termination_pairs_12 = list(product(material2_slab_terminations, substrate_second_slab_terminations)) \n", + "print(\"Termination Pairs for Second Interface (Material2, First Interface Substrate)\")\n", + "for idx, termination_pair in enumerate(termination_pairs_12):\n", + " print(f\" {idx}: {termination_pair}\")" + ], + "metadata": { + "collapsed": false + }, + "id": "41b3d541c1ebfe5a", + "execution_count": null + }, + { + "cell_type": "markdown", + "source": [ + "### 3.3. Select Termination Pair for Second Interface\n" + ], + "metadata": { + "collapsed": false + }, + "id": "822c79480c3d7965" + }, + { + "cell_type": "markdown", + "source": [ + "### 3.4. Initialize Interface Configuration for Second Interface\n" + ], + "metadata": { + "collapsed": false + }, + "id": "796e3604d6bd4c60" + }, + { + "cell_type": "code", + "outputs": [], + "source": [ + "from mat3ra.made.tools.build.interface import InterfaceConfiguration\n", + "\n", + "material2_termination, substrate_second_termination = termination_pairs_12[TERMINATION_PAIR_INDEX_12]\n", + "interface_configuration_12 = InterfaceConfiguration(\n", + " film_configuration=material2_slab_configuration,\n", + " substrate_configuration=substrate_second_slab_configuration,\n", + " film_termination=material2_termination,\n", + " substrate_termination=substrate_second_termination,\n", + " distance_z=INTERFACE_12_DISTANCE,\n", + " vacuum=SECOND_INTERFACE_VACUUM\n", + ")" + ], + "metadata": { + "collapsed": false + }, + "id": "fa7e6b937d2b78a0", + "execution_count": null + }, + { + "cell_type": "markdown", + "source": [ + "### 3.5. Set Strain Matching Parameters and Generate Second Interface\n" + ], + "metadata": { + "collapsed": false + }, + "id": "3816e1b290f7e5d0" + }, + { + "cell_type": "code", + "outputs": [], + "source": [ + "zsl_strain_matching_parameters_12 = ZSLStrainMatchingParameters(\n", + " max_area=MAX_AREA_12,\n", + " max_area_ratio_tol=0.2,\n", + " max_angle_tol=0.1,\n", + " max_length_tol=0.1,\n", + ")\n", + "\n", + "matched_interfaces_builder_12 = ZSLStrainMatchingInterfaceBuilder(\n", + " build_parameters=ZSLStrainMatchingInterfaceBuilderParameters(\n", + " strain_matching_parameters=zsl_strain_matching_parameters_12\n", + " )\n", + ")\n", + "\n", + "interfaces_12_sorted = matched_interfaces_builder_12.get_materials(configuration=interface_configuration_12)" + ], + "metadata": { + "collapsed": false + }, + "id": "6f30c6961f7abbfe", + "execution_count": null + }, + { + "cell_type": "markdown", + "source": [ + "### 3.6. Plot and Select Second Interface\n" + ], + "metadata": { + "collapsed": false + }, + "id": "32ded9bdae6ef429" + }, + { + "cell_type": "code", + "outputs": [], + "source": [ + "plot_strain_vs_atoms(interfaces_12_sorted, PLOT_SETTINGS)\n" + ], + "metadata": { + "collapsed": false + }, + "id": "43f233403393eb2a", + "execution_count": null + }, + { + "cell_type": "markdown", + "source": [ + "### 3.7. Preview the Second Interface (Final Heterostructure)\n" + ], + "metadata": { + "collapsed": false + }, + "id": "ed109941d5e29522" + }, + { + "cell_type": "code", + "outputs": [], + "source": [ + "selected_interface_12 = interfaces_12_sorted[INTERFACE_12_INDEX]\n", + "\n", + "visualize(selected_interface_12, repetitions=[1, 1, 1])\n", + "visualize(selected_interface_12, repetitions=[1, 1, 1], rotation=\"-90x\")" + ], + "metadata": { + "collapsed": false + }, + "id": "fffbf9243911a98", + "execution_count": null + }, + { + "cell_type": "markdown", + "source": [ + "## 4. Create the Final Heterostructure\n" + ], + "metadata": { + "collapsed": false + }, + "id": "e98176e806c4aace" + }, + { + "cell_type": "code", + "outputs": [], + "source": [ + "from mat3ra.made.tools.build.utils import merge_materials\n", + "from mat3ra.made.tools.build.supercell import create_supercell\n", + "\n", + "bottom_half = translate_to_z_level(selected_interface_12, \"bottom\")\n", + "top_half = create_supercell(bottom_half, scaling_factor=[1, 1, -1])\n", + "visualize([top_half, bottom_half], title=\"Top Half\", rotation=\"-90x\")\n", + "\n", + "final_stack = merge_materials([bottom_half, top_half])\n", + "\n", + "\n", + "visualize(final_stack, title=\"Final Heterostructure (First Interface + Material2)\")\n", + "visualize(final_stack, rotation=\"-90x\", title=\"Final Heterostructure (First Interface + Material2) Rotated\")" + ], + "metadata": { + "collapsed": false + }, + "id": "47f9a1aa1578c37", + "execution_count": null + }, + { + "cell_type": "markdown", + "source": [ + "## 5. Pass the Final Heterostructure to the Outside Runtime\n", + "\n", + "Pass the resulting heterostructure with an adjusted name to `set_materials()`.\n" + ], + "metadata": { + "collapsed": false + }, + "id": "946d5a41156bc1e1" + }, + { + "cell_type": "code", + "outputs": [], + "source": [ + "from utils.jupyterlite import set_materials\n", + "\n", + "final_stack.name = f\"Heterostructure: {material0.name} - {material1.name} - {material2.name}\"\n", + "\n", + "set_materials(final_stack)" + ], + "metadata": { + "collapsed": false + }, + "id": "1b466c32b0d82431", + "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 +} diff --git a/other/materials_designer/specific_examples/heterostructure_high_k_metal_gate_stack.ipynb b/other/materials_designer/specific_examples/heterostructure_high_k_metal_gate_stack.ipynb new file mode 100644 index 00000000..c6d8084c --- /dev/null +++ b/other/materials_designer/specific_examples/heterostructure_high_k_metal_gate_stack.ipynb @@ -0,0 +1,507 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "e96bfb09b980e52b", + "metadata": { + "collapsed": false + }, + "source": [] + }, + { + "cell_type": "markdown", + "id": "3ae4cc7db0846f04", + "metadata": { + "collapsed": false + }, + "source": [ + "# Create High-k Metal Gate Stack Tutorial\n", + "\n", + "This notebook demonstrates how to create a high-k metal gate stack heterostructure with four materials: Si (substrate), SiO2 (gate oxide), HfO2 (high-k dielectric), and TiN (metal gate).\n", + "\n", + "We'll create a representation of the material from the image without the amorphous step.\n", + "\n", + "\"High-k\n" + ] + }, + { + "cell_type": "markdown", + "id": "f1db6e522c6716dc", + "metadata": { + "collapsed": false + }, + "source": [ + "## 1. Configuration Parameters\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "813b06d4d77a8507", + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "# Global parameters\n", + "MAX_AREA = 200 # Maximum area for strain matching\n", + "MAX_AREA_RATIO_TOL = 0.25 # Maximum area ratio tolerance for strain matching\n", + "MAX_ANGLE_TOLERANCE = 0.15 # Maximum angle tolerance for strain matching\n", + "MAX_LENGTH_TOLERANCE = 0.15 # Maximum length tolerance for strain matching\n", + "\n", + "# Structure parameters for each layer\n", + "STRUCTURE_PARAMS = [\n", + " {\n", + " # Silicon substrate\n", + " \"slab_params\": {\n", + " \"miller_indices\": (1, 0, 0),\n", + " \"thickness\": 4, # atomic layers\n", + " \"vacuum\": 5.0, # Angstroms\n", + " \"use_orthogonal_z\": True\n", + " },\n", + " \"interface_distance\": None # No interface for substrate\n", + " },\n", + " {\n", + " # SiO2 layer\n", + " \"slab_params\": {\n", + " \"miller_indices\": (1,0,0),\n", + " \"thickness\": 3,\n", + " \"vacuum\": 5.0,\n", + " \"use_orthogonal_z\": True\n", + " },\n", + " \"interface_distance\": 2.5 # Distance to Si substrate\n", + " },\n", + " {\n", + " # HfO2 layer\n", + " \"slab_params\": {\n", + " \"miller_indices\": (0,0,1),\n", + " \"thickness\": 4,\n", + " \"vacuum\": 0.5,\n", + " \"xy_supercell_matrix\": [[1, 0], [0, 2]],\n", + " \"use_orthogonal_z\": True\n", + " },\n", + " \"interface_distance\": 2.5 # Distance to SiO2\n", + " },\n", + " {\n", + " # TiN layer\n", + " \"slab_params\": {\n", + " \"miller_indices\": (0,0, 1),\n", + " \"thickness\": 3,\n", + " \"vacuum\": 10.0, # Add vacuum to final layer\n", + " \"use_orthogonal_z\": True\n", + " },\n", + " \"interface_distance\": 2.5 # Distance to HfO2\n", + " }\n", + "]\n", + "\n", + "INTERFACE_1_INDEX = 11 " + ] + }, + { + "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": "a671bb0a66616061" + }, + { + "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\")" + ], + "metadata": { + "collapsed": false + }, + "id": "c11956a7712639b9", + "execution_count": null + }, + { + "cell_type": "markdown", + "source": [ + "### 1.3. Get input material\n", + "In this notebook we will use materials from Standata." + ], + "metadata": { + "collapsed": false + }, + "id": "15599efa4b241366" + }, + { + "cell_type": "code", + "outputs": [], + "source": [ + "from mat3ra.made.material import Material\n", + "from mat3ra.standata.materials import Materials\n", + "\n", + "materials_1 = [\n", + " Material(Materials.get_by_name_first_match(\"SiO2\")), # SiO2\n", + " Material(Materials.get_by_name_first_match(\"Silicon\")), # Si substrate\n", + " ]\n", + "materials_2 = [\n", + " Material(Materials.get_by_name_first_match(\"HfO2\")), # HfO2\n", + " Material(Materials.get_by_name_first_match(\"TiN\")), # TiN\n", + "]" + ], + "metadata": { + "collapsed": false + }, + "id": "474383a5e0f70d6", + "execution_count": null + }, + { + "cell_type": "markdown", + "id": "9fe9b39b05f1dc7e", + "metadata": { + "collapsed": false + }, + "source": [ + "## 2. Create Si/SiO2 Interface\n", + "### 2.1. Create Si/SiO2 Interface" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "59c8eb0e549ee69e", + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "from mat3ra.made.tools.build.slab import SlabConfiguration, get_terminations, create_slab, PymatgenSlabGeneratorParameters\n", + "from mat3ra.made.tools.build.interface import (\n", + " InterfaceConfiguration,\n", + " ZSLStrainMatchingParameters,\n", + " ZSLStrainMatchingInterfaceBuilder,\n", + " ZSLStrainMatchingInterfaceBuilderParameters\n", + ")\n", + "from utils.visualize import visualize_materials as visualize\n", + "\n", + "film_params = STRUCTURE_PARAMS[1]\n", + "substrate_params = STRUCTURE_PARAMS[0]\n", + "\n", + "film_config = SlabConfiguration(\n", + " bulk=materials_1[1],\n", + " **film_params[\"slab_params\"]\n", + ")\n", + "\n", + "substrate_config = SlabConfiguration(\n", + " bulk=materials_1[0],\n", + " **substrate_params[\"slab_params\"]\n", + ")\n", + "params = PymatgenSlabGeneratorParameters(symmetrize = False)\n", + "\n", + "film_terminations = get_terminations(film_config, build_parameters=params)\n", + "substrate_terminations = get_terminations(substrate_config, build_parameters=params)\n", + "\n", + "film_termination = film_terminations[0]\n", + "substrate_termination = substrate_terminations[0]\n", + "\n", + "\n", + "interface_config = InterfaceConfiguration(\n", + " film_configuration=film_config,\n", + " substrate_configuration=substrate_config,\n", + " film_termination=film_termination,\n", + " substrate_termination=substrate_termination,\n", + " distance=film_params[\"interface_distance\"],\n", + " vacuum=film_params[\"slab_params\"][\"vacuum\"]\n", + ")\n", + "\n", + "\n", + "\n", + "builder = ZSLStrainMatchingInterfaceBuilder(\n", + " build_parameters=ZSLStrainMatchingInterfaceBuilderParameters(\n", + " strain_matching_parameters=ZSLStrainMatchingParameters(max_area=MAX_AREA, max_area_ratio_tol=MAX_AREA_RATIO_TOL, max_angle_tol=MAX_ANGLE_TOLERANCE, max_length_tol=MAX_LENGTH_TOLERANCE)\n", + " )\n", + ")\n", + "\n", + "interfaces = builder.get_materials(configuration=interface_config)\n", + "interface_1 = interfaces[INTERFACE_1_INDEX]" + ] + }, + { + "cell_type": "markdown", + "source": [ + "### 2.2. Visualize the Si/SiO2 Interface" + ], + "metadata": { + "collapsed": false + }, + "id": "b4d5e3261b720c9d" + }, + { + "cell_type": "code", + "outputs": [], + "source": [ + "visualize(\n", + " interface_1,\n", + " repetitions=[1, 1, 1],\n", + " title=\"Si/SiO2 Interface\"\n", + ")\n", + "\n", + "visualize(\n", + " interface_1,\n", + " repetitions=[1, 1, 1],\n", + " title=\"Si/SiO2 Interface\",\n", + " rotation='-90x'\n", + ")\n" + ], + "metadata": { + "collapsed": false + }, + "id": "49c046cf4517ad91", + "execution_count": null + }, + { + "cell_type": "markdown", + "id": "4cc11d87adc5d979", + "metadata": { + "collapsed": false + }, + "source": [ + "## 3. Add HfO2 Layer\n", + "### 3.1. Add a layer with SimpleInterfaceBuilder" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "670fc0c56e8b22b5", + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "from mat3ra.made.tools.build.interface import SimpleInterfaceBuilder, SimpleInterfaceBuilderParameters\n", + "\n", + "film_params = STRUCTURE_PARAMS[2]\n", + "\n", + "film_config = SlabConfiguration(\n", + " bulk=materials_2[0],\n", + " **film_params[\"slab_params\"]\n", + ")\n", + "\n", + "hfo2_slab= create_slab(film_config, build_parameters=params)\n", + "\n", + "film_config = SlabConfiguration(\n", + " bulk=hfo2_slab,\n", + " **film_params[\"slab_params\"]\n", + ")\n", + "\n", + "substrate_config = SlabConfiguration(\n", + " bulk=interface_1,\n", + " miller_indices=(0,0,1)\n", + ")\n", + "\n", + "film_terminations = get_terminations(film_config, build_parameters=params)\n", + "substrate_terminations = get_terminations(substrate_config, build_parameters=params)\n", + "\n", + "print(\"Film terminations:\", film_terminations)\n", + "print(\"Substrate terminations:\", substrate_terminations)\n", + "\n", + "\n", + "interface_config = InterfaceConfiguration(\n", + " film_configuration=film_config,\n", + " substrate_configuration=substrate_config,\n", + " film_termination=film_terminations[0],\n", + " substrate_termination=substrate_terminations[0],\n", + " distance=film_params[\"interface_distance\"],\n", + " vacuum=film_params[\"slab_params\"][\"vacuum\"]\n", + ")\n", + "\n", + "builder = SimpleInterfaceBuilder(build_parameters=SimpleInterfaceBuilderParameters(scale_film=True, build_slabs=False))\n", + "interface_2 = builder.get_material(configuration=interface_config)\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "source": [ + "### 3.2. Visualize the Si/SiO2/HfO2 Interface" + ], + "metadata": { + "collapsed": false + }, + "id": "6f62d46be77dbf7f" + }, + { + "cell_type": "code", + "outputs": [], + "source": [ + "visualize(\n", + " interface_2,\n", + " repetitions=[1, 1, 1],\n", + " title=\"Si/SiO2/HfO2 Interface\"\n", + ")\n", + "\n", + "visualize(\n", + " interface_2,\n", + " repetitions=[1, 1, 1],\n", + " title=\"Si/SiO2/HfO2 Interface\",\n", + " rotation='-90x'\n", + ")" + ], + "metadata": { + "collapsed": false + }, + "id": "5ddc3d75b43a3926", + "execution_count": null + }, + { + "cell_type": "markdown", + "id": "93705fda2bacc16e", + "metadata": { + "collapsed": false + }, + "source": [ + "## 4. Add TiN Layer\n", + "### 4.1. Add a layer with SimpleInterfaceBuilder" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "46bce40c8d46f8bb", + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "from mat3ra.made.tools.build.supercell import create_supercell\n", + "\n", + "film_params = STRUCTURE_PARAMS[3]\n", + "\n", + "interface_2 = create_supercell(interface_2, scaling_factor=[1, 1, -1])\n", + "\n", + "film_config = SlabConfiguration(\n", + " bulk=materials_2[1],\n", + " **film_params[\"slab_params\"]\n", + ")\n", + "\n", + "tin_slab = create_slab(film_config, build_parameters=params)\n", + "\n", + "film_config = SlabConfiguration(\n", + " bulk=tin_slab,\n", + " **film_params[\"slab_params\"]\n", + ")\n", + "\n", + "substrate_config = SlabConfiguration(\n", + " bulk=interface_2,\n", + " miller_indices=(0,0,1)\n", + ")\n", + "\n", + "film_terminations = get_terminations(film_config, build_parameters=params)\n", + "substrate_terminations = get_terminations(substrate_config, build_parameters=params)\n", + "\n", + "print(\"Film terminations:\", film_terminations)\n", + "print(\"Substrate terminations:\", substrate_terminations)\n", + "\n", + "interface_config = InterfaceConfiguration(\n", + " film_configuration=film_config,\n", + " substrate_configuration=substrate_config,\n", + " film_termination=film_terminations[0],\n", + " substrate_termination=substrate_terminations[0],\n", + " distance=film_params[\"interface_distance\"],\n", + " vacuum=film_params[\"slab_params\"][\"vacuum\"]\n", + ")\n", + "\n", + "builder = SimpleInterfaceBuilder(build_parameters=SimpleInterfaceBuilderParameters(scale_film=True, build_slabs=False))\n", + "\n", + "interface_3 = builder.get_material(configuration=interface_config)\n", + "# invert the interface along the z-axis to match example\n", + "interface_3 = create_supercell(interface_3, scaling_factor=[1, 1, -1])\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "source": [ + "### 4.2. Visualize the Si/SiO2/HfO2/TiN Interface" + ], + "metadata": { + "collapsed": false + }, + "id": "de4385aa81264e6b" + }, + { + "cell_type": "code", + "outputs": [], + "source": [ + "visualize(\n", + " interface_3,\n", + " repetitions=[1, 1, 1],\n", + " title=\"Si/SiO2/HfO2/TiN Interface\"\n", + ")\n", + "\n", + "visualize(\n", + " interface_3,\n", + " repetitions=[1, 1, 1],\n", + " title=\"Si/SiO2/HfO2/TiN Interface\",\n", + " rotation='-90x'\n", + ")" + ], + "metadata": { + "collapsed": false + }, + "id": "2b3fda71c801aeff" + }, + { + "cell_type": "markdown", + "id": "ae16540b54491e35", + "metadata": { + "collapsed": false + }, + "source": [ + "## 5. Save final material\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "803792030da3a97", + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "from utils.jupyterlite import download_content_to_file\n", + "\n", + "download_content_to_file(interface_3, \"heterostructure_high_k_metal_gate.json\")" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": ".venv-3.11", + "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.11.7" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +}