From e2a5d0e1422dcc9f57f6926c77e2f2be261b306e Mon Sep 17 00:00:00 2001 From: VsevolodX <79542055+VsevolodX@users.noreply.github.com> Date: Tue, 24 Dec 2024 20:54:22 -0800 Subject: [PATCH 01/14] wip: rough implementation of heterostack (takes toooooo long) --- .../heterostructure_high_k_metal_gate.ipynb | 293 ++++++++++++++++++ 1 file changed, 293 insertions(+) create mode 100644 other/materials_designer/specific_examples/heterostructure_high_k_metal_gate.ipynb diff --git a/other/materials_designer/specific_examples/heterostructure_high_k_metal_gate.ipynb b/other/materials_designer/specific_examples/heterostructure_high_k_metal_gate.ipynb new file mode 100644 index 00000000..6f9b02c3 --- /dev/null +++ b/other/materials_designer/specific_examples/heterostructure_high_k_metal_gate.ipynb @@ -0,0 +1,293 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "source": [], + "metadata": { + "collapsed": false + }, + "id": "e96bfb09b980e52b" + }, + { + "cell_type": "markdown", + "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" + ], + "metadata": { + "collapsed": false + }, + "id": "3ae4cc7db0846f04" + }, + { + "cell_type": "markdown", + "source": [ + "## 1. Configuration Parameters\n" + ], + "metadata": { + "collapsed": false + }, + "id": "f1db6e522c6716dc" + }, + { + "cell_type": "code", + "outputs": [], + "source": [ + "# Global parameters\n", + "MAX_AREA = 800 # Maximum area for all interfaces\n", + "MAX_AREA_RATIO_TOL = 0.09 # Maximum area ratio tolerance for strain matching\n", + "MAX_ANGLE_TOLERANCE = 0.03 # Maximum angle tolerance for strain matching\n", + "MAX_LENGTH_TOLERANCE = 0.03 # Maximum length tolerance for strain matching\n", + "FINAL_VACUUM = 20.0 # Final vacuum spacing in Angstroms\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\": 3, # atomic layers\n", + " \"vacuum\": 0, # Angstroms\n", + " \"xy_supercell_matrix\": [[1, 0], [0, 1]],\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\": 2,\n", + " \"vacuum\": 0,\n", + " \"xy_supercell_matrix\": [[1, 0], [0, 1]],\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, 1, 1),\n", + " \"thickness\": 3,\n", + " \"vacuum\": 0,\n", + " \"xy_supercell_matrix\": [[1, 0], [0, 1]],\n", + " \"use_orthogonal_z\": True\n", + " },\n", + " \"interface_distance\": 2.8 # Distance to SiO2\n", + " },\n", + " {\n", + " # TiN layer\n", + " \"slab_params\": {\n", + " \"miller_indices\": (0, 0, 1),\n", + " \"thickness\": 3,\n", + " \"vacuum\": FINAL_VACUUM, # Add vacuum to final layer\n", + " \"xy_supercell_matrix\": [[1, 0], [0, 1]],\n", + " \"use_orthogonal_z\": True\n", + " },\n", + " \"interface_distance\": 2.5 # Distance to HfO2\n", + " }\n", + "]\n", + "\n", + "INTERFACE_INDEX=[4,0,0]\n" + ], + "metadata": { + "collapsed": false + }, + "id": "813b06d4d77a8507", + "execution_count": null + }, + { + "cell_type": "markdown", + "source": [ + "## 2. Environment Setup and Material Loading\n" + ], + "metadata": { + "collapsed": false + }, + "id": "b076b018bd5efe10" + }, + { + "cell_type": "code", + "outputs": [], + "source": [ + "from mat3ra.standata.materials import Materials\n", + "from mat3ra.made.material import Material\n", + "from mat3ra.made.tools.build.slab import SlabConfiguration, get_terminations, create_slab\n", + "from mat3ra.made.tools.build.interface import (\n", + " InterfaceConfiguration,\n", + " ZSLStrainMatchingParameters,\n", + " ZSLStrainMatchingInterfaceBuilder,\n", + " ZSLStrainMatchingInterfaceBuilderParameters\n", + ")\n", + "from mat3ra.made.tools.modify import translate_to_z_level\n", + "from utils.visualize import visualize_materials as visualize\n", + "\n", + "# Load materials from Standata\n", + "materials = [\n", + " Material(Materials.get_by_name_first_match(\"Silicon\")), # Si substrate\n", + " Material(Materials.get_by_name_first_match(\"SiO2\")), # SiO2\n", + " Material(Materials.get_by_name_first_match(\"HfO2\")), # HfO2\n", + " Material(Materials.get_by_name_first_match(\"TiN\")) # TiN\n", + "]\n" + ], + "metadata": { + "collapsed": false + }, + "id": "deaa451cfe2f8dc0", + "execution_count": null + }, + { + "cell_type": "markdown", + "source": [ + "## 3. Build Stack Layer by Layer\n", + "\n", + "Now we'll build the stack sequentially, starting with the substrate and adding each layer one by one.\n" + ], + "metadata": { + "collapsed": false + }, + "id": "9a6950d3f27d1c8" + }, + { + "cell_type": "code", + "outputs": [], + "source": [ + "# Start with substrate (first material)\n", + "current_structure = materials[0]\n", + "print(\"Starting with substrate:\", materials[0].name)\n", + "\n", + "# Iterate through remaining materials to build interfaces\n", + "for i in range(1, len(materials)):\n", + " print(f\"\\nBuilding interface {i} of {len(materials)-1}...\")\n", + " print(f\"Adding {materials[i].name} to {materials[i-1].name}\")\n", + " \n", + " # Get parameters for current interface\n", + " film_params = STRUCTURE_PARAMS[i]\n", + " substrate_params = STRUCTURE_PARAMS[i-1]\n", + " \n", + " # Create slab configurations\n", + " film_config = SlabConfiguration(\n", + " bulk=materials[i],\n", + " **film_params[\"slab_params\"]\n", + " )\n", + " \n", + " substrate_config = SlabConfiguration(\n", + " bulk=current_structure,\n", + " **substrate_params[\"slab_params\"]\n", + " )\n", + " \n", + " # Get terminations\n", + " film_terminations = get_terminations(film_config)\n", + " substrate_terminations = get_terminations(substrate_config)\n", + " \n", + " # Use first termination pair for simplicity\n", + " film_termination = film_terminations[0]\n", + " substrate_termination = substrate_terminations[0]\n", + " \n", + " print(f\"Using terminations: {film_termination} (film) and {substrate_termination} (substrate)\")\n", + " \n", + " # Create interface configuration\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", + " # Set up strain matching and build interface\n", + " strain_params = 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", + " builder = ZSLStrainMatchingInterfaceBuilder(\n", + " build_parameters=ZSLStrainMatchingInterfaceBuilderParameters(\n", + " strain_matching_parameters=strain_params\n", + " )\n", + " )\n", + " \n", + " # Generate and sort interfaces\n", + " interfaces = builder.get_materials(configuration=interface_config)\n", + " \n", + " # Select the first interface (lowest strain, smallest area)\n", + " current_structure = interfaces[INTERFACE_INDEX[i-1]]\n", + " \n", + " # Translate structure to prepare for next layer\n", + " # current_structure = translate_to_z_level(current_structure, \"top\")\n", + " \n", + " # Visualize current state\n", + " visualize(\n", + " current_structure,\n", + " repetitions=[1, 1, 1],\n", + " title=f\"After adding {materials[i].name}\"\n", + " )\n", + " \n", + " # # Print interface statistics\n", + " # print(f\"\\nLayer {i} Statistics:\")\n", + " # print(f\"Number of atoms: {len(current_structure.atoms)}\")\n", + " print(f\"Height: {current_structure.lattice.c:.2f} Å\")\n", + " print(f\"Surface area: {current_structure.lattice.volume()/current_structure.lattice.c:.2f} Ų\")\n" + ], + "metadata": { + "collapsed": false + }, + "id": "88208178c30708a1", + "execution_count": null + }, + { + "cell_type": "markdown", + "source": [ + "## 4. Final Structure Visualization and Analysis\n" + ], + "metadata": { + "collapsed": false + }, + "id": "ae16540b54491e35" + }, + { + "cell_type": "code", + "outputs": [], + "source": [ + "# Visualize final structure\n", + "visualize(\n", + " current_structure,\n", + " repetitions=[3, 3, 1],\n", + " title=\"Complete High-k Metal Gate Stack\"\n", + ")\n", + "\n", + "# Print final analysis\n", + "print(\"\\nFinal Structure Analysis:\")\n", + "print(f\"Total number of atoms: {len(current_structure.atoms)}\")\n", + "print(f\"Total height: {current_structure.lattice.c:.2f} Å\")\n", + "print(f\"Surface area: {current_structure.lattice.surface_area:.2f} Ų\")\n", + "print(\"\\nLayer composition:\")\n", + "for element, count in current_structure.composition.items():\n", + " print(f\" {element}: {count} atoms\")" + ], + "metadata": { + "collapsed": false + }, + "id": "14be386aeddd4b" + } + ], + "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 +} From 7251a9e8080b93bb6d222b6455cd266d963c2e9c Mon Sep 17 00:00:00 2001 From: VsevolodX <79542055+VsevolodX@users.noreply.github.com> Date: Wed, 25 Dec 2024 19:31:28 -0800 Subject: [PATCH 02/14] update: create layer by layer with simple builder --- .../heterostructure_high_k_metal_gate.ipynb | 421 +++++++++++++----- 1 file changed, 313 insertions(+), 108 deletions(-) diff --git a/other/materials_designer/specific_examples/heterostructure_high_k_metal_gate.ipynb b/other/materials_designer/specific_examples/heterostructure_high_k_metal_gate.ipynb index 6f9b02c3..c43986ec 100644 --- a/other/materials_designer/specific_examples/heterostructure_high_k_metal_gate.ipynb +++ b/other/materials_designer/specific_examples/heterostructure_high_k_metal_gate.ipynb @@ -35,10 +35,10 @@ "outputs": [], "source": [ "# Global parameters\n", - "MAX_AREA = 800 # Maximum area for all interfaces\n", - "MAX_AREA_RATIO_TOL = 0.09 # Maximum area ratio tolerance for strain matching\n", - "MAX_ANGLE_TOLERANCE = 0.03 # Maximum angle tolerance for strain matching\n", - "MAX_LENGTH_TOLERANCE = 0.03 # Maximum length tolerance for strain matching\n", + "MAX_AREA = [200,200,260] # 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", "FINAL_VACUUM = 20.0 # Final vacuum spacing in Angstroms\n", "\n", "# Structure parameters for each layer\n", @@ -48,7 +48,7 @@ " \"slab_params\": {\n", " \"miller_indices\": (1, 0, 0),\n", " \"thickness\": 3, # atomic layers\n", - " \"vacuum\": 0, # Angstroms\n", + " \"vacuum\": FINAL_VACUUM, # Angstroms\n", " \"xy_supercell_matrix\": [[1, 0], [0, 1]],\n", " \"use_orthogonal_z\": True\n", " },\n", @@ -58,8 +58,8 @@ " # SiO2 layer\n", " \"slab_params\": {\n", " \"miller_indices\": (1,0,0),\n", - " \"thickness\": 2,\n", - " \"vacuum\": 0,\n", + " \"thickness\": 3,\n", + " \"vacuum\": FINAL_VACUUM,\n", " \"xy_supercell_matrix\": [[1, 0], [0, 1]],\n", " \"use_orthogonal_z\": True\n", " },\n", @@ -68,9 +68,9 @@ " {\n", " # HfO2 layer\n", " \"slab_params\": {\n", - " \"miller_indices\": (0, 1, 1),\n", + " \"miller_indices\": (0,0,1),\n", " \"thickness\": 3,\n", - " \"vacuum\": 0,\n", + " \"vacuum\": FINAL_VACUUM,\n", " \"xy_supercell_matrix\": [[1, 0], [0, 1]],\n", " \"use_orthogonal_z\": True\n", " },\n", @@ -89,13 +89,17 @@ " }\n", "]\n", "\n", - "INTERFACE_INDEX=[4,0,0]\n" + "INTERFACE_1_INDEX = 11\n" ], "metadata": { - "collapsed": false + "collapsed": false, + "ExecuteTime": { + "end_time": "2024-12-26T03:28:25.952389Z", + "start_time": "2024-12-26T03:28:25.938943Z" + } }, "id": "813b06d4d77a8507", - "execution_count": null + "execution_count": 1 }, { "cell_type": "markdown", @@ -124,113 +128,313 @@ "from utils.visualize import visualize_materials as visualize\n", "\n", "# Load materials from Standata\n", - "materials = [\n", - " Material(Materials.get_by_name_first_match(\"Silicon\")), # Si substrate\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", + " Material(Materials.get_by_name_first_match(\"TiN\")), # TiN\n", "]\n" ], "metadata": { - "collapsed": false + "collapsed": false, + "ExecuteTime": { + "end_time": "2024-12-26T03:28:32.102086Z", + "start_time": "2024-12-26T03:28:25.972101Z" + } }, "id": "deaa451cfe2f8dc0", - "execution_count": null + "execution_count": 2 }, { "cell_type": "markdown", "source": [ - "## 3. Build Stack Layer by Layer\n", - "\n", - "Now we'll build the stack sequentially, starting with the substrate and adding each layer one by one.\n" + "## 3. Create Si/SiO2 Interface" ], "metadata": { "collapsed": false }, - "id": "9a6950d3f27d1c8" + "id": "9fe9b39b05f1dc7e" }, { "cell_type": "code", - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Interface will be built with terminations: (Si_P4/mmm_1, Si_Pmmm_1)\n", + "Interface will be built with terminations: (Si_P4/mmm_1, Si_Pmmm_1)\n" + ] + }, + { + "data": { + "text/plain": "GridBox(children=(VBox(children=(Label(value='O108Si198 - Si/SiO2 Interface - rotation: 0x,0y,0z', layout=Layo…", + "application/vnd.jupyter.widget-view+json": { + "version_major": 2, + "version_minor": 0, + "model_id": "b7946978dc3b4866bd8e88363811f666" + } + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/plain": "GridBox(children=(VBox(children=(Label(value='O108Si198 - Si/SiO2 Interface - rotation: -90x', layout=Layout(a…", + "application/vnd.jupyter.widget-view+json": { + "version_major": 2, + "version_minor": 0, + "model_id": "69f28eeac9b7456f8643c8a1a28805cd" + } + }, + "metadata": {}, + "output_type": "display_data" + } + ], "source": [ - "# Start with substrate (first material)\n", - "current_structure = materials[0]\n", - "print(\"Starting with substrate:\", materials[0].name)\n", - "\n", - "# Iterate through remaining materials to build interfaces\n", - "for i in range(1, len(materials)):\n", - " print(f\"\\nBuilding interface {i} of {len(materials)-1}...\")\n", - " print(f\"Adding {materials[i].name} to {materials[i-1].name}\")\n", - " \n", - " # Get parameters for current interface\n", - " film_params = STRUCTURE_PARAMS[i]\n", - " substrate_params = STRUCTURE_PARAMS[i-1]\n", - " \n", - " # Create slab configurations\n", - " film_config = SlabConfiguration(\n", - " bulk=materials[i],\n", - " **film_params[\"slab_params\"]\n", - " )\n", - " \n", - " substrate_config = SlabConfiguration(\n", - " bulk=current_structure,\n", - " **substrate_params[\"slab_params\"]\n", - " )\n", - " \n", - " # Get terminations\n", - " film_terminations = get_terminations(film_config)\n", - " substrate_terminations = get_terminations(substrate_config)\n", - " \n", - " # Use first termination pair for simplicity\n", - " film_termination = film_terminations[0]\n", - " substrate_termination = substrate_terminations[0]\n", - " \n", - " print(f\"Using terminations: {film_termination} (film) and {substrate_termination} (substrate)\")\n", - " \n", - " # Create interface configuration\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", - " # Set up strain matching and build interface\n", - " strain_params = 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", - " builder = ZSLStrainMatchingInterfaceBuilder(\n", - " build_parameters=ZSLStrainMatchingInterfaceBuilderParameters(\n", - " strain_matching_parameters=strain_params\n", - " )\n", - " )\n", - " \n", - " # Generate and sort interfaces\n", - " interfaces = builder.get_materials(configuration=interface_config)\n", - " \n", - " # Select the first interface (lowest strain, smallest area)\n", - " current_structure = interfaces[INTERFACE_INDEX[i-1]]\n", - " \n", - " # Translate structure to prepare for next layer\n", - " # current_structure = translate_to_z_level(current_structure, \"top\")\n", - " \n", - " # Visualize current state\n", - " visualize(\n", - " current_structure,\n", - " repetitions=[1, 1, 1],\n", - " title=f\"After adding {materials[i].name}\"\n", + "from mat3ra.made.tools.build.slab import PymatgenSlabGeneratorParameters\n", + "\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[0], max_area_ratio_tol=MAX_AREA_RATIO_TOL, max_angle_tol=MAX_ANGLE_TOLERANCE, max_length_tol=MAX_LENGTH_TOLERANCE)\n", " )\n", - " \n", - " # # Print interface statistics\n", - " # print(f\"\\nLayer {i} Statistics:\")\n", - " # print(f\"Number of atoms: {len(current_structure.atoms)}\")\n", - " print(f\"Height: {current_structure.lattice.c:.2f} Å\")\n", - " print(f\"Surface area: {current_structure.lattice.volume()/current_structure.lattice.c:.2f} Ų\")\n" + ")\n", + "\n", + "interfaces = builder.get_materials(configuration=interface_config)\n", + "\n", + "visualize(\n", + " interfaces[11],\n", + " repetitions=[1, 1, 1],\n", + " title=\"Si/SiO2 Interface\"\n", + ")\n", + "\n", + "visualize(\n", + " interfaces[11],\n", + " repetitions=[1, 1, 1],\n", + " title=\"Si/SiO2 Interface\",\n", + " rotation='-90x'\n", + ")\n", + "\n", + "interface_1 = interfaces[INTERFACE_1_INDEX]\n", + "\n", + "\n", + "\n" + ], + "metadata": { + "collapsed": false, + "ExecuteTime": { + "end_time": "2024-12-26T03:28:47.420848Z", + "start_time": "2024-12-26T03:28:32.104683Z" + } + }, + "id": "59c8eb0e549ee69e", + "execution_count": 3 + }, + { + "cell_type": "markdown", + "source": [ + "## 2. Add HfO2 Layer" + ], + "metadata": { + "collapsed": false + }, + "id": "4cc11d87adc5d979" + }, + { + "cell_type": "code", + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Film terminations: [O2_P-1_2, O2_P4/mmm_1, Hf_P4/mmm_1, O2_P4/mmm_1]\n", + "Substrate terminations: [Si_Pmmm_12, Si_Pmmm_12, Si_Pmmm_12, Si_Pmmm_12, Si_Pmmm_12, Si_Pmmm_12, Si_Pmmm_12, Si_Pmmm_12, Si_Pmmm_12, Si_Pmmm_12, Si_Pmmm_12, Si_Pmmm_12, Si_Pmmm_6, O2_Pmmm_6, O2_Pmmm_6, O2_Pmmm_6, Si_Pmmm_6, O2_Pmmm_6, O2_Pmmm_6, O2_Pmmm_6, Si_Pmmm_6, Si_P2_1/m_12, O2_Pmmm_6, O2_Pmmm_6, O2_Pmmm_6, Si_Pmmm_6, O2_Pmmm_6, O2_Pmmm_6, O2_Pmmm_6, Si_Pmmm_6, Si_P2_1/m_12, O2_Pmmm_6, O2_Pmmm_6, O2_Pmmm_6, Si_Pmmm_6, O2_Pmmm_6, O2_Pmmm_6, O2_Pmmm_6, Si_Pmmm_6]\n" + ] + }, + { + "data": { + "text/plain": "GridBox(children=(VBox(children=(Label(value='Hf12O132Si198 - Si/SiO2/HfO2 Interface - rotation: 0x,0y,0z', la…", + "application/vnd.jupyter.widget-view+json": { + "version_major": 2, + "version_minor": 0, + "model_id": "8f7d841f788047fa925b782ebc450285" + } + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/plain": "GridBox(children=(VBox(children=(Label(value='Hf12O132Si198 - Si/SiO2/HfO2 Interface - rotation: -90x', layout…", + "application/vnd.jupyter.widget-view+json": { + "version_major": 2, + "version_minor": 0, + "model_id": "b6b8285f0ac04a6c91bf16e64e3e0700" + } + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "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", + "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))\n", + "interface = builder.get_material(configuration=interface_config)\n", + "\n", + "visualize(\n", + " interface,\n", + " repetitions=[1, 1, 1],\n", + " title=\"Si/SiO2/HfO2 Interface\"\n", + ")\n", + "\n", + "visualize(\n", + " interface,\n", + " repetitions=[1, 1, 1],\n", + " title=\"Si/SiO2/HfO2 Interface\",\n", + " rotation='-90x'\n", + ")\n" + ], + "metadata": { + "collapsed": false, + "ExecuteTime": { + "end_time": "2024-12-26T03:29:20.477794Z", + "start_time": "2024-12-26T03:28:47.423339Z" + } + }, + "id": "670fc0c56e8b22b5", + "execution_count": 4 + }, + { + "cell_type": "markdown", + "source": [ + "## 3. Add TiN Layer" ], "metadata": { "collapsed": false }, - "id": "88208178c30708a1", + "id": "93705fda2bacc16e" + }, + { + "cell_type": "code", + "outputs": [], + "source": [ + "film_params = STRUCTURE_PARAMS[3]\n", + "\n", + "film_config = SlabConfiguration(\n", + " bulk=materials_2[1],\n", + " **film_params[\"slab_params\"]\n", + ")\n", + "\n", + "substrate_config = SlabConfiguration(\n", + " bulk=interface,\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))\n", + "\n", + "interface = builder.get_material(configuration=interface_config)\n", + "\n", + "visualize(\n", + " interface,\n", + " repetitions=[1, 1, 1],\n", + " title=\"Si/SiO2/HfO2/TiN Interface\"\n", + ")\n", + "\n", + "visualize(\n", + " interface,\n", + " repetitions=[1, 1, 1],\n", + " title=\"Si/SiO2/HfO2/TiN Interface\",\n", + " rotation='-90x'\n", + ")\n", + "\n" + ], + "metadata": { + "collapsed": false, + "is_executing": true, + "ExecuteTime": { + "start_time": "2024-12-26T03:29:20.482245Z" + } + }, + "id": "46bce40c8d46f8bb", "execution_count": null }, { @@ -247,26 +451,27 @@ "cell_type": "code", "outputs": [], "source": [ - "# Visualize final structure\n", + "from utils.jupyterlite import set_materials\n", + "\n", + "visualize(\n", + " interface,\n", + " repetitions=[1, 1, 1],\n", + " title=\"Si/SiO2/HfO2/TiN Interface\",\n", + ")\n", + "\n", "visualize(\n", - " current_structure,\n", - " repetitions=[3, 3, 1],\n", - " title=\"Complete High-k Metal Gate Stack\"\n", + " interface,\n", + " repetitions=[1, 1, 1],\n", + " title=\"Si/SiO2/HfO2/TiN Interface\",\n", + " rotation='-90x'\n", ")\n", "\n", - "# Print final analysis\n", - "print(\"\\nFinal Structure Analysis:\")\n", - "print(f\"Total number of atoms: {len(current_structure.atoms)}\")\n", - "print(f\"Total height: {current_structure.lattice.c:.2f} Å\")\n", - "print(f\"Surface area: {current_structure.lattice.surface_area:.2f} Ų\")\n", - "print(\"\\nLayer composition:\")\n", - "for element, count in current_structure.composition.items():\n", - " print(f\" {element}: {count} atoms\")" + "set_materials(interface)" ], "metadata": { "collapsed": false }, - "id": "14be386aeddd4b" + "id": "803792030da3a97" } ], "metadata": { From 25d04a83d5b8e97777bc95062a95efb417e4c116 Mon Sep 17 00:00:00 2001 From: VsevolodX <79542055+VsevolodX@users.noreply.github.com> Date: Wed, 25 Dec 2024 20:03:30 -0800 Subject: [PATCH 03/14] update: cleanups --- .../heterostructure_high_k_metal_gate.ipynb | 143 ++++-------------- 1 file changed, 30 insertions(+), 113 deletions(-) diff --git a/other/materials_designer/specific_examples/heterostructure_high_k_metal_gate.ipynb b/other/materials_designer/specific_examples/heterostructure_high_k_metal_gate.ipynb index c43986ec..047f25d9 100644 --- a/other/materials_designer/specific_examples/heterostructure_high_k_metal_gate.ipynb +++ b/other/materials_designer/specific_examples/heterostructure_high_k_metal_gate.ipynb @@ -39,7 +39,7 @@ "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", - "FINAL_VACUUM = 20.0 # Final vacuum spacing in Angstroms\n", + "VACUUM = 10.0 # Final vacuum spacing in Angstroms\n", "\n", "# Structure parameters for each layer\n", "STRUCTURE_PARAMS = [\n", @@ -47,9 +47,8 @@ " # Silicon substrate\n", " \"slab_params\": {\n", " \"miller_indices\": (1, 0, 0),\n", - " \"thickness\": 3, # atomic layers\n", - " \"vacuum\": FINAL_VACUUM, # Angstroms\n", - " \"xy_supercell_matrix\": [[1, 0], [0, 1]],\n", + " \"thickness\": 4, # atomic layers\n", + " \"vacuum\": VACUUM, # Angstroms\n", " \"use_orthogonal_z\": True\n", " },\n", " \"interface_distance\": None # No interface for substrate\n", @@ -59,8 +58,7 @@ " \"slab_params\": {\n", " \"miller_indices\": (1,0,0),\n", " \"thickness\": 3,\n", - " \"vacuum\": FINAL_VACUUM,\n", - " \"xy_supercell_matrix\": [[1, 0], [0, 1]],\n", + " \"vacuum\": VACUUM,\n", " \"use_orthogonal_z\": True\n", " },\n", " \"interface_distance\": 2.5 # Distance to Si substrate\n", @@ -70,19 +68,17 @@ " \"slab_params\": {\n", " \"miller_indices\": (0,0,1),\n", " \"thickness\": 3,\n", - " \"vacuum\": FINAL_VACUUM,\n", - " \"xy_supercell_matrix\": [[1, 0], [0, 1]],\n", + " \"vacuum\": VACUUM,\n", " \"use_orthogonal_z\": True\n", " },\n", - " \"interface_distance\": 2.8 # Distance to SiO2\n", + " \"interface_distance\": 2.5 # Distance to SiO2\n", " },\n", " {\n", " # TiN layer\n", " \"slab_params\": {\n", - " \"miller_indices\": (0, 0, 1),\n", + " \"miller_indices\": (0,0, 1),\n", " \"thickness\": 3,\n", - " \"vacuum\": FINAL_VACUUM, # Add vacuum to final layer\n", - " \"xy_supercell_matrix\": [[1, 0], [0, 1]],\n", + " \"vacuum\": VACUUM, # Add vacuum to final layer\n", " \"use_orthogonal_z\": True\n", " },\n", " \"interface_distance\": 2.5 # Distance to HfO2\n", @@ -92,14 +88,10 @@ "INTERFACE_1_INDEX = 11\n" ], "metadata": { - "collapsed": false, - "ExecuteTime": { - "end_time": "2024-12-26T03:28:25.952389Z", - "start_time": "2024-12-26T03:28:25.938943Z" - } + "collapsed": false }, "id": "813b06d4d77a8507", - "execution_count": 1 + "execution_count": null }, { "cell_type": "markdown", @@ -138,14 +130,10 @@ "]\n" ], "metadata": { - "collapsed": false, - "ExecuteTime": { - "end_time": "2024-12-26T03:28:32.102086Z", - "start_time": "2024-12-26T03:28:25.972101Z" - } + "collapsed": false }, "id": "deaa451cfe2f8dc0", - "execution_count": 2 + "execution_count": null }, { "cell_type": "markdown", @@ -159,40 +147,7 @@ }, { "cell_type": "code", - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Interface will be built with terminations: (Si_P4/mmm_1, Si_Pmmm_1)\n", - "Interface will be built with terminations: (Si_P4/mmm_1, Si_Pmmm_1)\n" - ] - }, - { - "data": { - "text/plain": "GridBox(children=(VBox(children=(Label(value='O108Si198 - Si/SiO2 Interface - rotation: 0x,0y,0z', layout=Layo…", - "application/vnd.jupyter.widget-view+json": { - "version_major": 2, - "version_minor": 0, - "model_id": "b7946978dc3b4866bd8e88363811f666" - } - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/plain": "GridBox(children=(VBox(children=(Label(value='O108Si198 - Si/SiO2 Interface - rotation: -90x', layout=Layout(a…", - "application/vnd.jupyter.widget-view+json": { - "version_major": 2, - "version_minor": 0, - "model_id": "69f28eeac9b7456f8643c8a1a28805cd" - } - }, - "metadata": {}, - "output_type": "display_data" - } - ], + "outputs": [], "source": [ "from mat3ra.made.tools.build.slab import PymatgenSlabGeneratorParameters\n", "\n", @@ -256,14 +211,10 @@ "\n" ], "metadata": { - "collapsed": false, - "ExecuteTime": { - "end_time": "2024-12-26T03:28:47.420848Z", - "start_time": "2024-12-26T03:28:32.104683Z" - } + "collapsed": false }, "id": "59c8eb0e549ee69e", - "execution_count": 3 + "execution_count": null }, { "cell_type": "markdown", @@ -277,40 +228,7 @@ }, { "cell_type": "code", - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Film terminations: [O2_P-1_2, O2_P4/mmm_1, Hf_P4/mmm_1, O2_P4/mmm_1]\n", - "Substrate terminations: [Si_Pmmm_12, Si_Pmmm_12, Si_Pmmm_12, Si_Pmmm_12, Si_Pmmm_12, Si_Pmmm_12, Si_Pmmm_12, Si_Pmmm_12, Si_Pmmm_12, Si_Pmmm_12, Si_Pmmm_12, Si_Pmmm_12, Si_Pmmm_6, O2_Pmmm_6, O2_Pmmm_6, O2_Pmmm_6, Si_Pmmm_6, O2_Pmmm_6, O2_Pmmm_6, O2_Pmmm_6, Si_Pmmm_6, Si_P2_1/m_12, O2_Pmmm_6, O2_Pmmm_6, O2_Pmmm_6, Si_Pmmm_6, O2_Pmmm_6, O2_Pmmm_6, O2_Pmmm_6, Si_Pmmm_6, Si_P2_1/m_12, O2_Pmmm_6, O2_Pmmm_6, O2_Pmmm_6, Si_Pmmm_6, O2_Pmmm_6, O2_Pmmm_6, O2_Pmmm_6, Si_Pmmm_6]\n" - ] - }, - { - "data": { - "text/plain": "GridBox(children=(VBox(children=(Label(value='Hf12O132Si198 - Si/SiO2/HfO2 Interface - rotation: 0x,0y,0z', la…", - "application/vnd.jupyter.widget-view+json": { - "version_major": 2, - "version_minor": 0, - "model_id": "8f7d841f788047fa925b782ebc450285" - } - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/plain": "GridBox(children=(VBox(children=(Label(value='Hf12O132Si198 - Si/SiO2/HfO2 Interface - rotation: -90x', layout…", - "application/vnd.jupyter.widget-view+json": { - "version_major": 2, - "version_minor": 0, - "model_id": "b6b8285f0ac04a6c91bf16e64e3e0700" - } - }, - "metadata": {}, - "output_type": "display_data" - } - ], + "outputs": [], "source": [ "from mat3ra.made.tools.build.interface import SimpleInterfaceBuilder, SimpleInterfaceBuilderParameters\n", "\n", @@ -342,7 +260,7 @@ " vacuum=film_params[\"slab_params\"][\"vacuum\"]\n", ")\n", "\n", - "builder = SimpleInterfaceBuilder(build_parameters=SimpleInterfaceBuilderParameters(scale_film=True))\n", + "builder = SimpleInterfaceBuilder(build_parameters=SimpleInterfaceBuilderParameters(scale_film=True, slab_as_is=True))\n", "interface = builder.get_material(configuration=interface_config)\n", "\n", "visualize(\n", @@ -359,14 +277,10 @@ ")\n" ], "metadata": { - "collapsed": false, - "ExecuteTime": { - "end_time": "2024-12-26T03:29:20.477794Z", - "start_time": "2024-12-26T03:28:47.423339Z" - } + "collapsed": false }, "id": "670fc0c56e8b22b5", - "execution_count": 4 + "execution_count": null }, { "cell_type": "markdown", @@ -382,8 +296,12 @@ "cell_type": "code", "outputs": [], "source": [ + "from mat3ra.made.tools.build.supercell import create_supercell\n", + "\n", "film_params = STRUCTURE_PARAMS[3]\n", "\n", + "interface = create_supercell(interface, scaling_factor=[1,1,-1])\n", + "\n", "film_config = SlabConfiguration(\n", " bulk=materials_2[1],\n", " **film_params[\"slab_params\"]\n", @@ -409,7 +327,7 @@ " vacuum=film_params[\"slab_params\"][\"vacuum\"]\n", ")\n", "\n", - "builder = SimpleInterfaceBuilder(build_parameters=SimpleInterfaceBuilderParameters(scale_film=True))\n", + "builder = SimpleInterfaceBuilder(build_parameters=SimpleInterfaceBuilderParameters(scale_film=True, slab_as_is=True))\n", "\n", "interface = builder.get_material(configuration=interface_config)\n", "\n", @@ -425,14 +343,12 @@ " title=\"Si/SiO2/HfO2/TiN Interface\",\n", " rotation='-90x'\n", ")\n", - "\n" + "\n", + "# invert the interface along the z-axis to match example\n", + "interface = create_supercell(interface, scaling_factor=[1,1,-1])" ], "metadata": { - "collapsed": false, - "is_executing": true, - "ExecuteTime": { - "start_time": "2024-12-26T03:29:20.482245Z" - } + "collapsed": false }, "id": "46bce40c8d46f8bb", "execution_count": null @@ -471,7 +387,8 @@ "metadata": { "collapsed": false }, - "id": "803792030da3a97" + "id": "803792030da3a97", + "execution_count": null } ], "metadata": { From c0eab5a7288622e1a669291012d9da89a6d28fd2 Mon Sep 17 00:00:00 2001 From: VsevolodX Date: Wed, 25 Dec 2024 22:11:15 -0800 Subject: [PATCH 04/14] update: use updates in made --- .../heterostructure_high_k_metal_gate.ipynb | 165 ++++++++++-------- 1 file changed, 90 insertions(+), 75 deletions(-) diff --git a/other/materials_designer/specific_examples/heterostructure_high_k_metal_gate.ipynb b/other/materials_designer/specific_examples/heterostructure_high_k_metal_gate.ipynb index 047f25d9..cf69d3eb 100644 --- a/other/materials_designer/specific_examples/heterostructure_high_k_metal_gate.ipynb +++ b/other/materials_designer/specific_examples/heterostructure_high_k_metal_gate.ipynb @@ -2,36 +2,41 @@ "cells": [ { "cell_type": "markdown", - "source": [], + "id": "e96bfb09b980e52b", "metadata": { "collapsed": false }, - "id": "e96bfb09b980e52b" + "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" - ], - "metadata": { - "collapsed": false - }, - "id": "3ae4cc7db0846f04" + ] }, { "cell_type": "markdown", - "source": [ - "## 1. Configuration Parameters\n" - ], + "id": "f1db6e522c6716dc", "metadata": { "collapsed": false }, - "id": "f1db6e522c6716dc" + "source": [ + "## 1. Configuration Parameters\n" + ] }, { "cell_type": "code", + "execution_count": 6, + "id": "813b06d4d77a8507", + "metadata": { + "collapsed": false + }, "outputs": [], "source": [ "# Global parameters\n", @@ -67,8 +72,9 @@ " # HfO2 layer\n", " \"slab_params\": {\n", " \"miller_indices\": (0,0,1),\n", - " \"thickness\": 3,\n", - " \"vacuum\": VACUUM,\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", @@ -86,25 +92,25 @@ "]\n", "\n", "INTERFACE_1_INDEX = 11\n" - ], - "metadata": { - "collapsed": false - }, - "id": "813b06d4d77a8507", - "execution_count": null + ] }, { "cell_type": "markdown", - "source": [ - "## 2. Environment Setup and Material Loading\n" - ], + "id": "b076b018bd5efe10", "metadata": { "collapsed": false }, - "id": "b076b018bd5efe10" + "source": [ + "## 2. Environment Setup and Material Loading\n" + ] }, { "cell_type": "code", + "execution_count": 7, + "id": "deaa451cfe2f8dc0", + "metadata": { + "collapsed": false + }, "outputs": [], "source": [ "from mat3ra.standata.materials import Materials\n", @@ -128,25 +134,25 @@ " Material(Materials.get_by_name_first_match(\"HfO2\")), # HfO2\n", " Material(Materials.get_by_name_first_match(\"TiN\")), # TiN\n", "]\n" - ], - "metadata": { - "collapsed": false - }, - "id": "deaa451cfe2f8dc0", - "execution_count": null + ] }, { "cell_type": "markdown", - "source": [ - "## 3. Create Si/SiO2 Interface" - ], + "id": "9fe9b39b05f1dc7e", "metadata": { "collapsed": false }, - "id": "9fe9b39b05f1dc7e" + "source": [ + "## 3. Create Si/SiO2 Interface" + ] }, { "cell_type": "code", + "execution_count": null, + "id": "59c8eb0e549ee69e", + "metadata": { + "collapsed": false + }, "outputs": [], "source": [ "from mat3ra.made.tools.build.slab import PymatgenSlabGeneratorParameters\n", @@ -209,25 +215,25 @@ "\n", "\n", "\n" - ], - "metadata": { - "collapsed": false - }, - "id": "59c8eb0e549ee69e", - "execution_count": null + ] }, { "cell_type": "markdown", - "source": [ - "## 2. Add HfO2 Layer" - ], + "id": "4cc11d87adc5d979", "metadata": { "collapsed": false }, - "id": "4cc11d87adc5d979" + "source": [ + "## 2. Add HfO2 Layer" + ] }, { "cell_type": "code", + "execution_count": null, + "id": "670fc0c56e8b22b5", + "metadata": { + "collapsed": false + }, "outputs": [], "source": [ "from mat3ra.made.tools.build.interface import SimpleInterfaceBuilder, SimpleInterfaceBuilderParameters\n", @@ -239,6 +245,13 @@ " **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", @@ -260,7 +273,7 @@ " vacuum=film_params[\"slab_params\"][\"vacuum\"]\n", ")\n", "\n", - "builder = SimpleInterfaceBuilder(build_parameters=SimpleInterfaceBuilderParameters(scale_film=True, slab_as_is=True))\n", + "builder = SimpleInterfaceBuilder(build_parameters=SimpleInterfaceBuilderParameters(scale_film=True, build_slabs=False))\n", "interface = builder.get_material(configuration=interface_config)\n", "\n", "visualize(\n", @@ -275,25 +288,25 @@ " title=\"Si/SiO2/HfO2 Interface\",\n", " rotation='-90x'\n", ")\n" - ], - "metadata": { - "collapsed": false - }, - "id": "670fc0c56e8b22b5", - "execution_count": null + ] }, { "cell_type": "markdown", - "source": [ - "## 3. Add TiN Layer" - ], + "id": "93705fda2bacc16e", "metadata": { "collapsed": false }, - "id": "93705fda2bacc16e" + "source": [ + "## 3. Add TiN Layer" + ] }, { "cell_type": "code", + "execution_count": null, + "id": "46bce40c8d46f8bb", + "metadata": { + "collapsed": false + }, "outputs": [], "source": [ "from mat3ra.made.tools.build.supercell import create_supercell\n", @@ -307,6 +320,13 @@ " **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,\n", " miller_indices=(0,0,1)\n", @@ -327,7 +347,7 @@ " vacuum=film_params[\"slab_params\"][\"vacuum\"]\n", ")\n", "\n", - "builder = SimpleInterfaceBuilder(build_parameters=SimpleInterfaceBuilderParameters(scale_film=True, slab_as_is=True))\n", + "builder = SimpleInterfaceBuilder(build_parameters=SimpleInterfaceBuilderParameters(scale_film=True, build_slabs=False))\n", "\n", "interface = builder.get_material(configuration=interface_config)\n", "\n", @@ -346,25 +366,25 @@ "\n", "# invert the interface along the z-axis to match example\n", "interface = create_supercell(interface, scaling_factor=[1,1,-1])" - ], - "metadata": { - "collapsed": false - }, - "id": "46bce40c8d46f8bb", - "execution_count": null + ] }, { "cell_type": "markdown", - "source": [ - "## 4. Final Structure Visualization and Analysis\n" - ], + "id": "ae16540b54491e35", "metadata": { "collapsed": false }, - "id": "ae16540b54491e35" + "source": [ + "## 4. Final Structure Visualization and Analysis\n" + ] }, { "cell_type": "code", + "execution_count": null, + "id": "803792030da3a97", + "metadata": { + "collapsed": false + }, "outputs": [], "source": [ "from utils.jupyterlite import set_materials\n", @@ -383,31 +403,26 @@ ")\n", "\n", "set_materials(interface)" - ], - "metadata": { - "collapsed": false - }, - "id": "803792030da3a97", - "execution_count": null + ] } ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": ".venv-3.11", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", - "version": 2 + "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.6" + "pygments_lexer": "ipython3", + "version": "3.11.7" } }, "nbformat": 4, From ed9d3911392cc398d3d146ccb6cf0c2432b62c02 Mon Sep 17 00:00:00 2001 From: VsevolodX <79542055+VsevolodX@users.noreply.github.com> Date: Thu, 26 Dec 2024 10:43:07 -0800 Subject: [PATCH 05/14] chore: restructure notebook --- .../heterostructure_high_k_metal_gate.ipynb | 224 ++++++++++++------ 1 file changed, 149 insertions(+), 75 deletions(-) diff --git a/other/materials_designer/specific_examples/heterostructure_high_k_metal_gate.ipynb b/other/materials_designer/specific_examples/heterostructure_high_k_metal_gate.ipynb index cf69d3eb..c1980027 100644 --- a/other/materials_designer/specific_examples/heterostructure_high_k_metal_gate.ipynb +++ b/other/materials_designer/specific_examples/heterostructure_high_k_metal_gate.ipynb @@ -32,7 +32,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": null, "id": "813b06d4d77a8507", "metadata": { "collapsed": false @@ -40,11 +40,10 @@ "outputs": [], "source": [ "# Global parameters\n", - "MAX_AREA = [200,200,260] # Maximum area for strain matching\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", - "VACUUM = 10.0 # Final vacuum spacing in Angstroms\n", "\n", "# Structure parameters for each layer\n", "STRUCTURE_PARAMS = [\n", @@ -53,7 +52,7 @@ " \"slab_params\": {\n", " \"miller_indices\": (1, 0, 0),\n", " \"thickness\": 4, # atomic layers\n", - " \"vacuum\": VACUUM, # Angstroms\n", + " \"vacuum\": 5.0, # Angstroms\n", " \"use_orthogonal_z\": True\n", " },\n", " \"interface_distance\": None # No interface for substrate\n", @@ -63,7 +62,7 @@ " \"slab_params\": {\n", " \"miller_indices\": (1,0,0),\n", " \"thickness\": 3,\n", - " \"vacuum\": VACUUM,\n", + " \"vacuum\": 5.0,\n", " \"use_orthogonal_z\": True\n", " },\n", " \"interface_distance\": 2.5 # Distance to Si substrate\n", @@ -84,48 +83,67 @@ " \"slab_params\": {\n", " \"miller_indices\": (0,0, 1),\n", " \"thickness\": 3,\n", - " \"vacuum\": VACUUM, # Add vacuum to final layer\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\n" + "INTERFACE_1_INDEX = 11\n", + "INTERFACE_2_INDEX = 0\n", + "INTERFACE_3_INDEX = 0\n" ] }, { "cell_type": "markdown", - "id": "b076b018bd5efe10", + "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 }, - "source": [ - "## 2. Environment Setup and Material Loading\n" - ] + "id": "a671bb0a66616061" }, { "cell_type": "code", - "execution_count": 7, - "id": "deaa451cfe2f8dc0", + "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.standata.materials import Materials\n", "from mat3ra.made.material import Material\n", - "from mat3ra.made.tools.build.slab import SlabConfiguration, get_terminations, create_slab\n", - "from mat3ra.made.tools.build.interface import (\n", - " InterfaceConfiguration,\n", - " ZSLStrainMatchingParameters,\n", - " ZSLStrainMatchingInterfaceBuilder,\n", - " ZSLStrainMatchingInterfaceBuilderParameters\n", - ")\n", - "from mat3ra.made.tools.modify import translate_to_z_level\n", - "from utils.visualize import visualize_materials as visualize\n", + "from mat3ra.standata.materials import Materials\n", "\n", - "# Load materials from Standata\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", @@ -133,8 +151,13 @@ "materials_2 = [\n", " Material(Materials.get_by_name_first_match(\"HfO2\")), # HfO2\n", " Material(Materials.get_by_name_first_match(\"TiN\")), # TiN\n", - "]\n" - ] + "]" + ], + "metadata": { + "collapsed": false + }, + "id": "474383a5e0f70d6", + "execution_count": null }, { "cell_type": "markdown", @@ -143,7 +166,8 @@ "collapsed": false }, "source": [ - "## 3. Create Si/SiO2 Interface" + "## 2. Create Si/SiO2 Interface\n", + "### 2.1. Create Si/SiO2 Interface" ] }, { @@ -155,8 +179,14 @@ }, "outputs": [], "source": [ - "from mat3ra.made.tools.build.slab import PymatgenSlabGeneratorParameters\n", - "\n", + "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", @@ -192,30 +222,46 @@ "\n", "builder = ZSLStrainMatchingInterfaceBuilder(\n", " build_parameters=ZSLStrainMatchingInterfaceBuilderParameters(\n", - " strain_matching_parameters=ZSLStrainMatchingParameters(max_area=MAX_AREA[0], max_area_ratio_tol=MAX_AREA_RATIO_TOL, max_angle_tol=MAX_ANGLE_TOLERANCE, max_length_tol=MAX_LENGTH_TOLERANCE)\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", - "\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", - " interfaces[11],\n", + " interface_1,\n", " repetitions=[1, 1, 1],\n", " title=\"Si/SiO2 Interface\"\n", ")\n", "\n", "visualize(\n", - " interfaces[11],\n", + " interface_1,\n", " repetitions=[1, 1, 1],\n", " title=\"Si/SiO2 Interface\",\n", " rotation='-90x'\n", - ")\n", - "\n", - "interface_1 = interfaces[INTERFACE_1_INDEX]\n", - "\n", - "\n", - "\n" - ] + ")\n" + ], + "metadata": { + "collapsed": false + }, + "id": "49c046cf4517ad91", + "execution_count": null }, { "cell_type": "markdown", @@ -224,7 +270,8 @@ "collapsed": false }, "source": [ - "## 2. Add HfO2 Layer" + "## 3. Add HfO2 Layer\n", + "### 3.1. Add a layer with SimpleInterfaceBuilder" ] }, { @@ -274,21 +321,41 @@ ")\n", "\n", "builder = SimpleInterfaceBuilder(build_parameters=SimpleInterfaceBuilderParameters(scale_film=True, build_slabs=False))\n", - "interface = builder.get_material(configuration=interface_config)\n", - "\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,\n", + " interface_2,\n", " repetitions=[1, 1, 1],\n", " title=\"Si/SiO2/HfO2 Interface\"\n", ")\n", "\n", "visualize(\n", - " interface,\n", + " interface_2,\n", " repetitions=[1, 1, 1],\n", " title=\"Si/SiO2/HfO2 Interface\",\n", " rotation='-90x'\n", - ")\n" - ] + ")" + ], + "metadata": { + "collapsed": false + }, + "id": "5ddc3d75b43a3926" }, { "cell_type": "markdown", @@ -297,7 +364,8 @@ "collapsed": false }, "source": [ - "## 3. Add TiN Layer" + "## 4. Add TiN Layer\n", + "### 4.1. Add a layer with SimpleInterfaceBuilder" ] }, { @@ -313,7 +381,7 @@ "\n", "film_params = STRUCTURE_PARAMS[3]\n", "\n", - "interface = create_supercell(interface, scaling_factor=[1,1,-1])\n", + "interface_2 = create_supercell(interface_2, scaling_factor=[1, 1, -1])\n", "\n", "film_config = SlabConfiguration(\n", " bulk=materials_2[1],\n", @@ -328,7 +396,7 @@ ")\n", "\n", "substrate_config = SlabConfiguration(\n", - " bulk=interface,\n", + " bulk=interface_2,\n", " miller_indices=(0,0,1)\n", ")\n", "\n", @@ -349,24 +417,43 @@ "\n", "builder = SimpleInterfaceBuilder(build_parameters=SimpleInterfaceBuilderParameters(scale_film=True, build_slabs=False))\n", "\n", - "interface = builder.get_material(configuration=interface_config)\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,\n", + " interface_3,\n", " repetitions=[1, 1, 1],\n", " title=\"Si/SiO2/HfO2/TiN Interface\"\n", ")\n", "\n", "visualize(\n", - " interface,\n", + " interface_3,\n", " repetitions=[1, 1, 1],\n", " title=\"Si/SiO2/HfO2/TiN Interface\",\n", " rotation='-90x'\n", - ")\n", - "\n", - "# invert the interface along the z-axis to match example\n", - "interface = create_supercell(interface, scaling_factor=[1,1,-1])" - ] + ")" + ], + "metadata": { + "collapsed": false + }, + "id": "2b3fda71c801aeff" }, { "cell_type": "markdown", @@ -375,7 +462,7 @@ "collapsed": false }, "source": [ - "## 4. Final Structure Visualization and Analysis\n" + "## 5. Save final material\n" ] }, { @@ -387,22 +474,9 @@ }, "outputs": [], "source": [ - "from utils.jupyterlite import set_materials\n", - "\n", - "visualize(\n", - " interface,\n", - " repetitions=[1, 1, 1],\n", - " title=\"Si/SiO2/HfO2/TiN Interface\",\n", - ")\n", - "\n", - "visualize(\n", - " interface,\n", - " repetitions=[1, 1, 1],\n", - " title=\"Si/SiO2/HfO2/TiN Interface\",\n", - " rotation='-90x'\n", - ")\n", + "from utils.jupyterlite import download_content_to_file\n", "\n", - "set_materials(interface)" + "download_content_to_file(interface_3, \"heterostructure_high_k_metal_gate.json\")" ] } ], From 34f41640a0f92363ad99048ccef494ea2b5ed796 Mon Sep 17 00:00:00 2001 From: VsevolodX <79542055+VsevolodX@users.noreply.github.com> Date: Thu, 26 Dec 2024 11:16:52 -0800 Subject: [PATCH 06/14] chore: cleanup: --- .../heterostructure_high_k_metal_gate.ipynb | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/other/materials_designer/specific_examples/heterostructure_high_k_metal_gate.ipynb b/other/materials_designer/specific_examples/heterostructure_high_k_metal_gate.ipynb index c1980027..e015236b 100644 --- a/other/materials_designer/specific_examples/heterostructure_high_k_metal_gate.ipynb +++ b/other/materials_designer/specific_examples/heterostructure_high_k_metal_gate.ipynb @@ -90,9 +90,7 @@ " }\n", "]\n", "\n", - "INTERFACE_1_INDEX = 11\n", - "INTERFACE_2_INDEX = 0\n", - "INTERFACE_3_INDEX = 0\n" + "INTERFACE_1_INDEX = 11 " ] }, { @@ -355,7 +353,8 @@ "metadata": { "collapsed": false }, - "id": "5ddc3d75b43a3926" + "id": "5ddc3d75b43a3926", + "execution_count": null }, { "cell_type": "markdown", From 24c881bd5c953d8a3a80714783b6daac04bf708a Mon Sep 17 00:00:00 2001 From: VsevolodX <79542055+VsevolodX@users.noreply.github.com> Date: Thu, 26 Dec 2024 11:19:56 -0800 Subject: [PATCH 07/14] update: add a new flag from made --- .../create_interface_with_no_strain_matching.ipynb | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) 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 From ecdf3388ec80da7f3d659d20d9fef13a997b1494 Mon Sep 17 00:00:00 2001 From: VsevolodX <79542055+VsevolodX@users.noreply.github.com> Date: Thu, 26 Dec 2024 12:16:18 -0800 Subject: [PATCH 08/14] update: add additional params for ZSL --- .../create_interface_with_min_strain_zsl.ipynb | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) 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": { From fb55d30983b97244eae676b11e5e8f38b71a895a Mon Sep 17 00:00:00 2001 From: VsevolodX <79542055+VsevolodX@users.noreply.github.com> Date: Thu, 26 Dec 2024 13:13:49 -0800 Subject: [PATCH 09/14] update :add manuscript inage --- .../heterostructure_high_k_metal_gate.ipynb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/other/materials_designer/specific_examples/heterostructure_high_k_metal_gate.ipynb b/other/materials_designer/specific_examples/heterostructure_high_k_metal_gate.ipynb index e015236b..c6d8084c 100644 --- a/other/materials_designer/specific_examples/heterostructure_high_k_metal_gate.ipynb +++ b/other/materials_designer/specific_examples/heterostructure_high_k_metal_gate.ipynb @@ -17,7 +17,11 @@ "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" + "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" ] }, { From 75417492cfc727ede04e16ab8ff32370c5696fd2 Mon Sep 17 00:00:00 2001 From: VsevolodX <79542055+VsevolodX@users.noreply.github.com> Date: Thu, 26 Dec 2024 13:23:23 -0800 Subject: [PATCH 10/14] chore: rename to match docs --- ...l_gate.ipynb => heterostructure_high_k_metal_gate_stack.ipynb} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename other/materials_designer/specific_examples/{heterostructure_high_k_metal_gate.ipynb => heterostructure_high_k_metal_gate_stack.ipynb} (100%) diff --git a/other/materials_designer/specific_examples/heterostructure_high_k_metal_gate.ipynb b/other/materials_designer/specific_examples/heterostructure_high_k_metal_gate_stack.ipynb similarity index 100% rename from other/materials_designer/specific_examples/heterostructure_high_k_metal_gate.ipynb rename to other/materials_designer/specific_examples/heterostructure_high_k_metal_gate_stack.ipynb From 1ad84d75dc8e68116fdc9fba3a6f9968e8868d67 Mon Sep 17 00:00:00 2001 From: VsevolodX <79542055+VsevolodX@users.noreply.github.com> Date: Thu, 26 Dec 2024 18:27:33 -0800 Subject: [PATCH 11/14] feat: add first implementation of 5-stack --- .../heterostructure_example_5_stack.ipynb | 805 ++++++++++++++++++ 1 file changed, 805 insertions(+) create mode 100644 other/materials_designer/specific_examples/heterostructure_example_5_stack.ipynb 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..5e0aeb1a --- /dev/null +++ b/other/materials_designer/specific_examples/heterostructure_example_5_stack.ipynb @@ -0,0 +1,805 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "source": [ + "# Create Heterostructure Example with Three Materials\n", + "\n", + "This notebook demonstrates how to create a heterostructure involving three different materials using a sequential interface creation approach. We first create an interface between **Material 0** and **Material 1**, and then use that interface as a substrate to add a film of **Material 2**.\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": [ + "# Enable interactive selection of terminations via UI prompt\n", + "IS_TERMINATIONS_SELECTION_INTERACTIVE = False \n", + "\n", + "# Indices and configurations for the three materials\n", + "MATERIAL_0_INDEX = 0\n", + "MATERIAL_1_INDEX = 1\n", + "MATERIAL_2_INDEX = 2\n", + "\n", + "# Interface parameters\n", + "MAX_AREA_01 = 100 # search area for the first interface\n", + "INTERFACE_01_INDEX = 11 # 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 = 3.0 # in Angstrom\n", + "FIRST_INTERFACE_VACUUM = 6.0 # in Angstrom\n", + "INTERFACE_12_DISTANCE = 3.0 # in Angstrom\n", + "FINAL_INTERFACE_VACUUM = 20.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 = 3 # 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 = 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 = 3 # in atomic layers\n", + "MATERIAL_2_VACUUM = 1 # 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", + "\n", + "\n", + "\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\", \"WS2\", \"HfO2\"]\n", + "materials = []\n", + "for name in names:\n", + " material = Material(Materials.get_by_name_first_match(name))\n", + " materials.append(material)\n", + " " + ], + "metadata": { + "collapsed": false + }, + "id": "3975b2f204b91dd7", + "execution_count": null + }, + { + "cell_type": "code", + "outputs": [], + "source": [ + "from utils.jupyterlite import get_materials\n", + "\n", + "# materials = get_materials(globals())\n", + "\n", + "material0 = materials[MATERIAL_0_INDEX]\n", + "\n", + "try: \n", + " material1 = materials[MATERIAL_1_INDEX]\n", + "except IndexError:\n", + " print(\"Please select Material 1. Material 1 is set to Material 0.\")\n", + " material1 = material0\n", + "\n", + "try:\n", + " material2 = materials[MATERIAL_2_INDEX]\n", + "except IndexError:\n", + " print(\"Please select Material 2. Material 2 is set to Material 0.\")\n", + " material2 = material0\n" + ], + "metadata": { + "collapsed": false + }, + "id": "e90d5bf2655f5e0f", + "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", + "\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", + "# Get possible terminations for the slabs\n", + "material1_slab_terminations = get_terminations(material1_slab_configuration)\n", + "material0_slab_terminations = get_terminations(material0_slab_configuration)\n", + "\n", + "# Visualize all possible terminations\n", + "material1_slabs = [create_slab(material1_slab_configuration, termination) for termination in material1_slab_terminations]\n", + "material0_slabs = [create_slab(material0_slab_configuration, termination) 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.3. Select Termination Pair for First Interface\n" + ], + "metadata": { + "collapsed": false + }, + "id": "e70e2a4ef133c9f" + }, + { + "cell_type": "code", + "outputs": [], + "source": [ + "from utils.io import ui_prompt_select_array_element_by_index, ui_prompt_select_array_element_by_index_pyodide\n", + "\n", + "termination_pair_index_01 = TERMINATION_PAIR_INDEX_01\n", + "\n", + "termination_pair_first = termination_pairs_01[termination_pair_index_01]\n", + "if IS_TERMINATIONS_SELECTION_INTERACTIVE:\n", + " if sys.platform == \"emscripten\":\n", + " termination_pair_first = await ui_prompt_select_array_element_by_index_pyodide(\n", + " termination_pairs_01,\n", + " element_name=\"Material1/Material0 termination pair\"\n", + " )\n", + " else:\n", + " termination_pair_first = ui_prompt_select_array_element_by_index(\n", + " termination_pairs_01,\n", + " element_name=\"Material1/Material0 termination pair\"\n", + " )\n" + ], + "metadata": { + "collapsed": false + }, + "id": "c99cb2e5bbcd24df", + "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_pair_first\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=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)\n", + "\n", + "# Select the first interface with the lowest strain and smallest number of atoms\n", + "selected_interfaces_01 = interfaces_01_sorted[INTERFACE_01_INDEX]\n" + ], + "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": [ + "visualize(selected_interfaces_01, repetitions=[1, 1, 1])\n", + "visualize(selected_interfaces_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": [ + "from mat3ra.made.tools.modify import translate_to_z_level\n", + "from mat3ra.made.tools.build.slab import SlabConfiguration, get_terminations, create_slab, \\\n", + " PymatgenSlabGeneratorParameters\n", + "\n", + "# Update substrate to be the first interface\n", + "# substrate_second = translate_to_z_level(selected_interfaces_01, \"top\")\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=translate_to_z_level(selected_interfaces_01, \"top\"),\n", + " miller_indices=(0, 0, 1), # Z-orientation for the first interface\n", + " thickness=1, # One unit cell thick\n", + " vacuum=5.0, \n", + " xy_supercell_matrix=MATERIAL_0_XY_SUPERCELL_MATRIX, # Adjust if necessary\n", + " use_orthogonal_z=MATERIAL_0_USE_ORTHOGONAL_Z\n", + ")\n", + "\n", + "\n", + "\n", + "params = PymatgenSlabGeneratorParameters(symmetrize=False)\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", + "\n", + "# visualize(\n", + "# [{\"material\": slab, \"title\": slab.metadata[\"build\"][\"termination\"]} for slab in material2_slabs],\n", + "# repetitions=[3, 3, 1],\n", + "# rotation=\"-90x\"\n", + "# )\n", + "# \n", + "# visualize(\n", + "# [{\"material\": slab, \"title\": slab.metadata[\"build\"][\"termination\"]} for slab in substrate_second_slabs],\n", + "# repetitions=[3, 3, 1],\n", + "# rotation=\"-90x\"\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": "code", + "outputs": [], + "source": [ + "termination_pair_index_12 = TERMINATION_PAIR_INDEX_12\n", + "\n", + "termination_pair_second = termination_pairs_12[termination_pair_index_12]\n", + "if IS_TERMINATIONS_SELECTION_INTERACTIVE:\n", + " if sys.platform == \"emscripten\":\n", + " termination_pair_second = await ui_prompt_select_array_element_by_index_pyodide(\n", + " termination_pairs_12,\n", + " element_name=\"Material2/First Interface termination pair\"\n", + " )\n", + " else:\n", + " termination_pair_second = ui_prompt_select_array_element_by_index(\n", + " termination_pairs_12,\n", + " element_name=\"Material2/First Interface termination pair\"\n", + " )" + ], + "metadata": { + "collapsed": false + }, + "id": "f9d2b5429447338e", + "execution_count": null + }, + { + "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_pair_second\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=INTERFACE_12_DISTANCE,\n", + " vacuum=FINAL_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", + "\n", + "# Select the first interface with the lowest strain and smallest number of atoms\n", + "interfaces_slice_range_12 = slice(0, 1)\n", + "selected_interface_12 = interfaces_12_sorted[1]" + ], + "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": [ + "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.supercell import create_supercell\n", + "\n", + "selected_interface_12_flipped = create_supercell(selected_interface_12, scaling_factor=[1, 1, -1])\n", + "\n", + "visualize(selected_interface_12, title=\"Final Heterostructure (First Interface + Material2)\")\n", + "visualize(selected_interface_12, 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_heterostructure = selected_interface_12_flipped\n", + "final_heterostructure.name = f\"Heterostructure: {material0.name} - {material1.name} - {material2.name}\"\n", + "\n", + "set_materials(final_heterostructure)" + ], + "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 +} From e6d747716e47e8f51aa3be0248100877ef22bd9f Mon Sep 17 00:00:00 2001 From: VsevolodX <79542055+VsevolodX@users.noreply.github.com> Date: Thu, 26 Dec 2024 21:15:43 -0800 Subject: [PATCH 12/14] update: change materials --- .../heterostructure_example_5_stack.ipynb | 212 +++++------------- 1 file changed, 51 insertions(+), 161 deletions(-) diff --git a/other/materials_designer/specific_examples/heterostructure_example_5_stack.ipynb b/other/materials_designer/specific_examples/heterostructure_example_5_stack.ipynb index 5e0aeb1a..7cdb7af2 100644 --- a/other/materials_designer/specific_examples/heterostructure_example_5_stack.ipynb +++ b/other/materials_designer/specific_examples/heterostructure_example_5_stack.ipynb @@ -3,9 +3,11 @@ { "cell_type": "markdown", "source": [ - "# Create Heterostructure Example with Three Materials\n", + "# 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", - "This notebook demonstrates how to create a heterostructure involving three different materials using a sequential interface creation approach. We first create an interface between **Material 0** and **Material 1**, and then use that interface as a substrate to add a film of **Material 2**.\n", "\n", "

Usage

\n", "\n", @@ -49,53 +51,42 @@ "cell_type": "code", "outputs": [], "source": [ - "# Enable interactive selection of terminations via UI prompt\n", - "IS_TERMINATIONS_SELECTION_INTERACTIVE = False \n", - "\n", - "# Indices and configurations for the three materials\n", - "MATERIAL_0_INDEX = 0\n", - "MATERIAL_1_INDEX = 1\n", - "MATERIAL_2_INDEX = 2\n", - "\n", "# Interface parameters\n", "MAX_AREA_01 = 100 # search area for the first interface\n", - "INTERFACE_01_INDEX = 11 # index of the selected 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 = 3.0 # in Angstrom\n", + "INTERFACE_01_DISTANCE = 6.0 # in Angstrom\n", "FIRST_INTERFACE_VACUUM = 6.0 # in Angstrom\n", - "INTERFACE_12_DISTANCE = 3.0 # in Angstrom\n", - "FINAL_INTERFACE_VACUUM = 20.0 # in Angstrom\n", + "INTERFACE_12_DISTANCE = 6.0 # in Angstrom\n", + "FINAL_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 = 3 # in Angstroms\n", + "MATERIAL_0_VACUUM = 3.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 = 0 # in Angstroms\n", + "MATERIAL_1_VACUUM = 3.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 = 3 # in atomic layers\n", - "MATERIAL_2_VACUUM = 1 # in Angstroms\n", + "MATERIAL_2_THICKNESS = 2 # in atomic layers\n", + "MATERIAL_2_VACUUM = 3.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", - "\n", - "\n", - "\n" + "TERMINATION_PAIR_INDEX_12 = 0\n" ], "metadata": { "collapsed": false @@ -151,11 +142,15 @@ "source": [ "from mat3ra.standata.materials import Materials\n", "from mat3ra.made.material import Material\n", - "names = [\"TiN\", \"WS2\", \"HfO2\"]\n", + "names = [\"TiN\", \"NbSe2\", \"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": { @@ -164,34 +159,6 @@ "id": "3975b2f204b91dd7", "execution_count": null }, - { - "cell_type": "code", - "outputs": [], - "source": [ - "from utils.jupyterlite import get_materials\n", - "\n", - "# materials = get_materials(globals())\n", - "\n", - "material0 = materials[MATERIAL_0_INDEX]\n", - "\n", - "try: \n", - " material1 = materials[MATERIAL_1_INDEX]\n", - "except IndexError:\n", - " print(\"Please select Material 1. Material 1 is set to Material 0.\")\n", - " material1 = material0\n", - "\n", - "try:\n", - " material2 = materials[MATERIAL_2_INDEX]\n", - "except IndexError:\n", - " print(\"Please select Material 2. Material 2 is set to Material 0.\")\n", - " material2 = material0\n" - ], - "metadata": { - "collapsed": false - }, - "id": "e90d5bf2655f5e0f", - "execution_count": null - }, { "cell_type": "markdown", "source": [ @@ -236,7 +203,8 @@ "cell_type": "code", "outputs": [], "source": [ - "from mat3ra.made.tools.build.slab import SlabConfiguration, get_terminations, create_slab\n", + "from mat3ra.made.tools.build.slab import SlabConfiguration, get_terminations, create_slab, \\\n", + " PymatgenSlabGeneratorParameters\n", "\n", "# Slab Configuration for Material 1\n", "material1_slab_configuration = SlabConfiguration(\n", @@ -258,13 +226,14 @@ " 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)\n", - "material0_slab_terminations = get_terminations(material0_slab_configuration)\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) for termination in material1_slab_terminations]\n", - "material0_slabs = [create_slab(material0_slab_configuration, termination) for termination in material0_slab_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", @@ -311,43 +280,6 @@ "id": "4e467693b61f0125", "execution_count": null }, - { - "cell_type": "markdown", - "source": [ - "### 2.3. Select Termination Pair for First Interface\n" - ], - "metadata": { - "collapsed": false - }, - "id": "e70e2a4ef133c9f" - }, - { - "cell_type": "code", - "outputs": [], - "source": [ - "from utils.io import ui_prompt_select_array_element_by_index, ui_prompt_select_array_element_by_index_pyodide\n", - "\n", - "termination_pair_index_01 = TERMINATION_PAIR_INDEX_01\n", - "\n", - "termination_pair_first = termination_pairs_01[termination_pair_index_01]\n", - "if IS_TERMINATIONS_SELECTION_INTERACTIVE:\n", - " if sys.platform == \"emscripten\":\n", - " termination_pair_first = await ui_prompt_select_array_element_by_index_pyodide(\n", - " termination_pairs_01,\n", - " element_name=\"Material1/Material0 termination pair\"\n", - " )\n", - " else:\n", - " termination_pair_first = ui_prompt_select_array_element_by_index(\n", - " termination_pairs_01,\n", - " element_name=\"Material1/Material0 termination pair\"\n", - " )\n" - ], - "metadata": { - "collapsed": false - }, - "id": "c99cb2e5bbcd24df", - "execution_count": null - }, { "cell_type": "markdown", "source": [ @@ -364,13 +296,13 @@ "source": [ "from mat3ra.made.tools.build.interface import InterfaceConfiguration\n", "\n", - "material1_termination, material0_termination = termination_pair_first\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=INTERFACE_01_DISTANCE,\n", + " distance_z=INTERFACE_01_DISTANCE,\n", " vacuum=FIRST_INTERFACE_VACUUM\n", ")\n" ], @@ -440,10 +372,7 @@ " \"Y_SCALE\": \"log\", # or linear\n", "}\n", "\n", - "plot_strain_vs_atoms(interfaces_01_sorted, PLOT_SETTINGS)\n", - "\n", - "# Select the first interface with the lowest strain and smallest number of atoms\n", - "selected_interfaces_01 = interfaces_01_sorted[INTERFACE_01_INDEX]\n" + "plot_strain_vs_atoms(interfaces_01_sorted, PLOT_SETTINGS)" ], "metadata": { "collapsed": false @@ -465,8 +394,10 @@ "cell_type": "code", "outputs": [], "source": [ - "visualize(selected_interfaces_01, repetitions=[1, 1, 1])\n", - "visualize(selected_interfaces_01, repetitions=[1, 1, 1], rotation=\"-90x\")" + "selected_interface_01 = interfaces_01_sorted[INTERFACE_01_INDEX]\n", + "\n", + "visualize(selected_interface_01, repetitions=[1, 1, 1])\n", + "visualize(selected_interface_01, repetitions=[1, 1, 1], rotation=\"-90x\")" ], "metadata": { "collapsed": false @@ -493,11 +424,7 @@ "outputs": [], "source": [ "from mat3ra.made.tools.modify import translate_to_z_level\n", - "from mat3ra.made.tools.build.slab import SlabConfiguration, get_terminations, create_slab, \\\n", - " PymatgenSlabGeneratorParameters\n", - "\n", - "# Update substrate to be the first interface\n", - "# substrate_second = translate_to_z_level(selected_interfaces_01, \"top\")\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", @@ -511,7 +438,7 @@ "\n", "# Slab Configuration for Substrate (First Interface)\n", "substrate_second_slab_configuration = SlabConfiguration(\n", - " bulk=translate_to_z_level(selected_interfaces_01, \"top\"),\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=5.0, \n", @@ -519,28 +446,13 @@ " use_orthogonal_z=MATERIAL_0_USE_ORTHOGONAL_Z\n", ")\n", "\n", - "\n", - "\n", - "params = PymatgenSlabGeneratorParameters(symmetrize=False)\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", - "\n", - "# visualize(\n", - "# [{\"material\": slab, \"title\": slab.metadata[\"build\"][\"termination\"]} for slab in material2_slabs],\n", - "# repetitions=[3, 3, 1],\n", - "# rotation=\"-90x\"\n", - "# )\n", - "# \n", - "# visualize(\n", - "# [{\"material\": slab, \"title\": slab.metadata[\"build\"][\"termination\"]} for slab in substrate_second_slabs],\n", - "# repetitions=[3, 3, 1],\n", - "# rotation=\"-90x\"\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 @@ -583,31 +495,6 @@ }, "id": "822c79480c3d7965" }, - { - "cell_type": "code", - "outputs": [], - "source": [ - "termination_pair_index_12 = TERMINATION_PAIR_INDEX_12\n", - "\n", - "termination_pair_second = termination_pairs_12[termination_pair_index_12]\n", - "if IS_TERMINATIONS_SELECTION_INTERACTIVE:\n", - " if sys.platform == \"emscripten\":\n", - " termination_pair_second = await ui_prompt_select_array_element_by_index_pyodide(\n", - " termination_pairs_12,\n", - " element_name=\"Material2/First Interface termination pair\"\n", - " )\n", - " else:\n", - " termination_pair_second = ui_prompt_select_array_element_by_index(\n", - " termination_pairs_12,\n", - " element_name=\"Material2/First Interface termination pair\"\n", - " )" - ], - "metadata": { - "collapsed": false - }, - "id": "f9d2b5429447338e", - "execution_count": null - }, { "cell_type": "markdown", "source": [ @@ -624,13 +511,13 @@ "source": [ "from mat3ra.made.tools.build.interface import InterfaceConfiguration\n", "\n", - "material2_termination, substrate_second_termination = termination_pair_second\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=INTERFACE_12_DISTANCE,\n", + " distance_z=INTERFACE_12_DISTANCE,\n", " vacuum=FINAL_INTERFACE_VACUUM\n", ")" ], @@ -689,11 +576,7 @@ "cell_type": "code", "outputs": [], "source": [ - "plot_strain_vs_atoms(interfaces_12_sorted, PLOT_SETTINGS)\n", - "\n", - "# Select the first interface with the lowest strain and smallest number of atoms\n", - "interfaces_slice_range_12 = slice(0, 1)\n", - "selected_interface_12 = interfaces_12_sorted[1]" + "plot_strain_vs_atoms(interfaces_12_sorted, PLOT_SETTINGS)\n" ], "metadata": { "collapsed": false @@ -715,6 +598,8 @@ "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\")" ], @@ -738,12 +623,18 @@ "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", - "selected_interface_12_flipped = create_supercell(selected_interface_12, scaling_factor=[1, 1, -1])\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(selected_interface_12, title=\"Final Heterostructure (First Interface + Material2)\")\n", - "visualize(selected_interface_12, rotation=\"-90x\", title=\"Final Heterostructure (First Interface + Material2) Rotated\")" + "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 @@ -769,10 +660,9 @@ "source": [ "from utils.jupyterlite import set_materials\n", "\n", - "final_heterostructure = selected_interface_12_flipped\n", - "final_heterostructure.name = f\"Heterostructure: {material0.name} - {material1.name} - {material2.name}\"\n", + "final_stack.name = f\"Heterostructure: {material0.name} - {material1.name} - {material2.name}\"\n", "\n", - "set_materials(final_heterostructure)" + "set_materials(final_stack)" ], "metadata": { "collapsed": false From bbe3ff50690a587a784e8386910e7398eb469cdf Mon Sep 17 00:00:00 2001 From: VsevolodX <79542055+VsevolodX@users.noreply.github.com> Date: Thu, 26 Dec 2024 21:26:16 -0800 Subject: [PATCH 13/14] update: some stuff --- .../heterostructure_example_5_stack.ipynb | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/other/materials_designer/specific_examples/heterostructure_example_5_stack.ipynb b/other/materials_designer/specific_examples/heterostructure_example_5_stack.ipynb index 7cdb7af2..83a05058 100644 --- a/other/materials_designer/specific_examples/heterostructure_example_5_stack.ipynb +++ b/other/materials_designer/specific_examples/heterostructure_example_5_stack.ipynb @@ -66,21 +66,21 @@ "# 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 = 3.0 # in Angstroms\n", + "MATERIAL_0_VACUUM = 6.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 = 3.0 # in Angstroms\n", + "MATERIAL_1_VACUUM = 6.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 = 3.0 # in Angstroms\n", + "MATERIAL_2_VACUUM = 6.0 # in Angstroms\n", "MATERIAL_2_XY_SUPERCELL_MATRIX = [[1, 0], [0, 1]]\n", "MATERIAL_2_USE_ORTHOGONAL_Z = True\n", "\n", @@ -205,6 +205,7 @@ "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", @@ -395,6 +396,7 @@ "outputs": [], "source": [ "selected_interface_01 = interfaces_01_sorted[INTERFACE_01_INDEX]\n", + "selected_interface_01 = translate_to_z_level(selected_interface_01, \"center\")\n", "\n", "visualize(selected_interface_01, repetitions=[1, 1, 1])\n", "visualize(selected_interface_01, repetitions=[1, 1, 1], rotation=\"-90x\")" @@ -408,7 +410,7 @@ { "cell_type": "markdown", "source": [ - "## 3. Create Second Interface (First Interface + Material 2)\n", + "??## 3. Create Second Interface (First Interface + Material 2)\n", "\n", "### 3.1. Configure Slabs and Select Termination Pair for Second Interface\n", "\n", @@ -423,7 +425,8 @@ "cell_type": "code", "outputs": [], "source": [ - "from mat3ra.made.tools.modify import translate_to_z_level\n", + "\n", + "\n", "from mat3ra.made.tools.build.slab import SlabConfiguration, get_terminations, create_slab\n", "\n", "# Slab Configuration for Material 2\n", From 33d05ef6f0dd05bafa3e11e6197700c005e6fb36 Mon Sep 17 00:00:00 2001 From: VsevolodX <79542055+VsevolodX@users.noreply.github.com> Date: Fri, 27 Dec 2024 10:33:26 -0800 Subject: [PATCH 14/14] update --- .../heterostructure_example_5_stack.ipynb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/other/materials_designer/specific_examples/heterostructure_example_5_stack.ipynb b/other/materials_designer/specific_examples/heterostructure_example_5_stack.ipynb index 83a05058..8c9d8592 100644 --- a/other/materials_designer/specific_examples/heterostructure_example_5_stack.ipynb +++ b/other/materials_designer/specific_examples/heterostructure_example_5_stack.ipynb @@ -61,26 +61,26 @@ "INTERFACE_01_DISTANCE = 6.0 # in Angstrom\n", "FIRST_INTERFACE_VACUUM = 6.0 # in Angstrom\n", "INTERFACE_12_DISTANCE = 6.0 # in Angstrom\n", - "FINAL_INTERFACE_VACUUM = 50.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 = 6.0 # in Angstroms\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 = 6.0 # in Angstroms\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 = 6.0 # in Angstroms\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", @@ -142,7 +142,7 @@ "source": [ "from mat3ra.standata.materials import Materials\n", "from mat3ra.made.material import Material\n", - "names = [\"TiN\", \"NbSe2\", \"HfO2.*ORC\"]\n", + "names = [\"TiN\", \"NbS2\", \"HfO2.*ORC\"]\n", "materials = []\n", "for name in names:\n", " material = Material(Materials.get_by_name_first_match(name))\n", @@ -396,7 +396,7 @@ "outputs": [], "source": [ "selected_interface_01 = interfaces_01_sorted[INTERFACE_01_INDEX]\n", - "selected_interface_01 = translate_to_z_level(selected_interface_01, \"center\")\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\")" @@ -444,7 +444,7 @@ " 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=5.0, \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", @@ -521,7 +521,7 @@ " film_termination=material2_termination,\n", " substrate_termination=substrate_second_termination,\n", " distance_z=INTERFACE_12_DISTANCE,\n", - " vacuum=FINAL_INTERFACE_VACUUM\n", + " vacuum=SECOND_INTERFACE_VACUUM\n", ")" ], "metadata": {