diff --git a/other/materials_designer/create_adatom_defect.ipynb b/other/materials_designer/create_adatom_defect.ipynb index 09859417..296c94f9 100644 --- a/other/materials_designer/create_adatom_defect.ipynb +++ b/other/materials_designer/create_adatom_defect.ipynb @@ -141,20 +141,28 @@ "metadata": {}, "cell_type": "code", "source": [ - "from mat3ra.made.tools.build.slab import SlabConfiguration, get_terminations, create_slab\n", + "from mat3ra.made.tools.analyze.lattice_planes import CrystalLatticePlanesMaterialAnalyzer\n", + "from mat3ra.made.tools.build.slab.helpers import create_slab\n", "from utils.visualize import visualize_materials as visualize\n", "\n", "material = materials[0]\n", - "slab_config = SlabConfiguration(\n", - " bulk=material,\n", + "# Create analyzer to get terminations\n", + "analyzer = CrystalLatticePlanesMaterialAnalyzer(material=material, miller_indices=MILLER_INDICES)\n", + "slab_terminations = analyzer.terminations\n", + "# Get termination from analyzer\n", + "terminations = analyzer.terminations\n", + "termination = terminations[0] # Use first termination\n", + "\n", + "slab = create_slab(\n", + " crystal=material,\n", + " termination=termination,\n", " miller_indices=MILLER_INDICES,\n", - " number_of_layers=SLAB_THICKNESS,\n", - " vacuum=VACUUM,\n", - " use_orthogonal_z=True,\n", - " xy_supercell_matrix=SUPERCELL_MATRIX\n", + " number_of_layers=1,\n", + " vacuum=0,\n", + " xy_supercell_matrix=[[1, 0], [0, 1]],\n", + " use_orthogonal_c=True,\n", + " use_conventional_cell=True\n", ")\n", - "termination = get_terminations(slab_config)[0]\n", - "slab = create_slab(slab_config, termination)\n", "visualize([{\"material\": slab, \"rotation\": \"0x\"}, {\"material\": slab, \"rotation\": \"-90x\"}], repetitions=[1, 1, 1])" ], "id": "8ea8b4402aef0cf0", diff --git a/other/materials_designer/create_cluster_sphere.ipynb b/other/materials_designer/create_cluster_sphere.ipynb index df44ee0e..3aa3a804 100644 --- a/other/materials_designer/create_cluster_sphere.ipynb +++ b/other/materials_designer/create_cluster_sphere.ipynb @@ -38,7 +38,6 @@ }, { "cell_type": "code", - "outputs": [], "source": [ "RADIUS = 4.5 # in Angstroms\n", "VACUUM = 10.0 # in Angstroms on each side\n", @@ -48,6 +47,7 @@ "collapsed": false }, "id": "9d8b1890b34d850a", + "outputs": [], "execution_count": null }, { @@ -63,7 +63,6 @@ }, { "cell_type": "code", - "outputs": [], "source": [ "import sys\n", "\n", @@ -80,6 +79,7 @@ "collapsed": false }, "id": "ef664b14457530fd", + "outputs": [], "execution_count": null }, { @@ -94,7 +94,6 @@ }, { "cell_type": "code", - "outputs": [], "source": [ "from utils.jupyterlite import get_materials\n", "\n", @@ -104,6 +103,7 @@ "collapsed": false }, "id": "be38fdda1984c654", + "outputs": [], "execution_count": null }, { @@ -118,21 +118,29 @@ }, { "cell_type": "code", - "outputs": [], "source": [ "from mat3ra.made.tools.build.supercell import create_supercell\n", - "from mat3ra.made.tools.build.slab import create_slab, SlabConfiguration\n", + "from mat3ra.made.tools.analyze.lattice_planes import CrystalLatticePlanesMaterialAnalyzer\n", + "from mat3ra.made.tools.build.slab.helpers import create_slab\n", "from utils.visualize import visualize_materials as visualize\n", "\n", - "slab_config = SlabConfiguration(\n", - " bulk=materials[0],\n", + "# Create analyzer to get terminations\n", + "analyzer = CrystalLatticePlanesMaterialAnalyzer(material=materials[0], miller_indices=Z_ORIENTATION)\n", + "\n", + "# Get termination from analyzer\n", + "terminations = analyzer.terminations\n", + "termination = terminations[0] # Use first termination\n", + "\n", + "slab = create_slab(\n", + " crystal=materials[0],\n", + " termination=termination,\n", " miller_indices=Z_ORIENTATION,\n", " number_of_layers=1,\n", " vacuum=0,\n", - " use_orthogonal_z=True\n", + " xy_supercell_matrix=[[1, 0], [0, 1]],\n", + " use_orthogonal_c=True,\n", + " use_conventional_cell=True\n", ")\n", - "\n", - "slab = create_slab(slab_config)\n", "length = slab.lattice.a\n", "sufficient_n = int(2 * RADIUS / length) + 1\n", "\n", @@ -145,6 +153,7 @@ "collapsed": false }, "id": "7fcb1e02e84c5f35", + "outputs": [], "execution_count": null }, { @@ -160,7 +169,6 @@ }, { "cell_type": "code", - "outputs": [], "source": [ "from mat3ra.made.tools.modify import filter_by_sphere, add_vacuum, add_vacuum_sides\n", "\n", @@ -172,6 +180,7 @@ "collapsed": false }, "id": "a990fa35742d7269", + "outputs": [], "execution_count": null }, { @@ -186,11 +195,10 @@ }, { "cell_type": "code", - "outputs": [], "source": [ "from mat3ra.made.lattice import Lattice\n", "\n", - "current_vector_1, current_vector_2, current_vector_3 = cluster.lattice.vectors\n", + "current_vector_1, current_vector_2, current_vector_3 = cluster.lattice.vector_arrays\n", "cubic_vector_1 = [current_vector_1[0], 0, 0]\n", "cubic_vector_2 = [0, current_vector_2[1], 0]\n", "cubic_vector_3 = [0, 0, current_vector_3[2]]\n", @@ -200,6 +208,7 @@ "collapsed": false }, "id": "4f78c4743b370c3b", + "outputs": [], "execution_count": null }, { @@ -214,7 +223,6 @@ }, { "cell_type": "code", - "outputs": [], "source": [ "visualize([{\"material\": slab, \"title\": \"Original material\"},\n", " {\"material\": cluster, \"title\": f\"Cluster\"}])\n", @@ -226,6 +234,7 @@ "collapsed": false }, "id": "509b18661a069e42", + "outputs": [], "execution_count": null }, { @@ -240,7 +249,6 @@ }, { "cell_type": "code", - "outputs": [], "source": [ "from utils.jupyterlite import set_materials\n", "\n", @@ -251,6 +259,7 @@ "collapsed": false }, "id": "61daa5afcbc078a9", + "outputs": [], "execution_count": null } ], diff --git a/other/materials_designer/create_cutout_box.ipynb b/other/materials_designer/create_cutout_box.ipynb index 1b623ff3..698992e3 100644 --- a/other/materials_designer/create_cutout_box.ipynb +++ b/other/materials_designer/create_cutout_box.ipynb @@ -41,7 +41,6 @@ }, { "cell_type": "code", - "outputs": [], "source": [ "# Box cutout parameters\n", "MIN_COORDINATE = [0.25, 0.25, 0.5]\n", @@ -53,7 +52,7 @@ " \"miller_indices\": (0, 0, 1),\n", " \"thickness\": 6,\n", " \"vacuum\": 10.0,\n", - " \"use_orthogonal_z\": True,\n", + " \"use_orthogonal_c\": True,\n", " \"xy_supercell_matrix\": [[10, 0], [0, 10]]\n", "}" ], @@ -61,6 +60,7 @@ "collapsed": false }, "id": "9d8b1890b34d850a", + "outputs": [], "execution_count": null }, { @@ -76,7 +76,6 @@ }, { "cell_type": "code", - "outputs": [], "source": [ "import sys\n", "\n", @@ -93,6 +92,7 @@ "collapsed": false }, "id": "ef664b14457530fd", + "outputs": [], "execution_count": null }, { @@ -107,7 +107,6 @@ }, { "cell_type": "code", - "outputs": [], "source": [ "from utils.jupyterlite import get_materials\n", "\n", @@ -117,6 +116,7 @@ "collapsed": false }, "id": "be38fdda1984c654", + "outputs": [], "execution_count": null }, { @@ -131,25 +131,24 @@ }, { "cell_type": "code", - "outputs": [], "source": [ - "from mat3ra.made.tools.build.slab import create_slab_if_not, SlabConfiguration\n", + "from mat3ra.made.tools.build.slab.helpers import create_slab\n", "\n", - "default_slab_config = SlabConfiguration(\n", - " bulk=materials[0],\n", + "# Create analyzer to get terminations\n", + "slab = create_slab(\n", + " crystal=materials[0],\n", " miller_indices=DEFAULT_SLAB_PARAMETERS[\"miller_indices\"],\n", " number_of_layers=DEFAULT_SLAB_PARAMETERS[\"thickness\"],\n", " vacuum=DEFAULT_SLAB_PARAMETERS[\"vacuum\"],\n", - " use_orthogonal_z=DEFAULT_SLAB_PARAMETERS[\"use_orthogonal_z\"],\n", + " use_orthogonal_c=DEFAULT_SLAB_PARAMETERS[\"use_orthogonal_c\"],\n", " xy_supercell_matrix=DEFAULT_SLAB_PARAMETERS[\"xy_supercell_matrix\"]\n", - ")\n", - "\n", - "slab = create_slab_if_not(materials[0], default_slab_config)" + ")" ], "metadata": { "collapsed": false }, "id": "bfce9928ba2d0c7e", + "outputs": [], "execution_count": null }, { @@ -164,7 +163,6 @@ }, { "cell_type": "code", - "outputs": [], "source": [ "from utils.visualize import visualize_materials as visualize\n", "\n", @@ -175,6 +173,7 @@ "collapsed": false }, "id": "7fcb1e02e84c5f35", + "outputs": [], "execution_count": null }, { @@ -190,7 +189,6 @@ }, { "cell_type": "code", - "outputs": [], "source": [ "from mat3ra.made.tools.modify import filter_by_box\n", "\n", @@ -206,6 +204,7 @@ "collapsed": false }, "id": "a990fa35742d7269", + "outputs": [], "execution_count": null }, { @@ -220,7 +219,6 @@ }, { "cell_type": "code", - "outputs": [], "source": [ "visualize([{\"material\": slab, \"title\": \"Original material\"},\n", " {\"material\": slab_with_box_cutout, \"title\": f\"Cluster\"}])\n", @@ -232,6 +230,7 @@ "collapsed": false }, "id": "509b18661a069e42", + "outputs": [], "execution_count": null }, { @@ -246,7 +245,6 @@ }, { "cell_type": "code", - "outputs": [], "source": [ "from utils.jupyterlite import set_materials\n", "\n", @@ -257,6 +255,7 @@ "collapsed": false }, "id": "61daa5afcbc078a9", + "outputs": [], "execution_count": null } ], diff --git a/other/materials_designer/create_cutout_custom_shape.ipynb b/other/materials_designer/create_cutout_custom_shape.ipynb index 6007074c..d73aa5d8 100644 --- a/other/materials_designer/create_cutout_custom_shape.ipynb +++ b/other/materials_designer/create_cutout_custom_shape.ipynb @@ -40,7 +40,6 @@ }, { "cell_type": "code", - "outputs": [], "source": [ "import sys\n", "\n", @@ -57,6 +56,7 @@ "collapsed": false }, "id": "280f9794a876678b", + "outputs": [], "execution_count": null }, { @@ -71,7 +71,6 @@ }, { "cell_type": "code", - "outputs": [], "source": [ "# Slab parameters\n", "MILLER_INDICES = (0, 0, 1)\n", @@ -93,6 +92,7 @@ "collapsed": false }, "id": "5177e239254e3601", + "outputs": [], "execution_count": null }, { @@ -107,7 +107,6 @@ }, { "cell_type": "code", - "outputs": [], "source": [ "from typing import List\n", "\n", @@ -178,6 +177,7 @@ "collapsed": false }, "id": "56c8227695643174", + "outputs": [], "execution_count": null }, { @@ -192,7 +192,6 @@ }, { "cell_type": "code", - "outputs": [], "source": [ "from utils.jupyterlite import get_materials\n", "\n", @@ -203,6 +202,7 @@ "collapsed": false }, "id": "ceebf2a5229da67c", + "outputs": [], "execution_count": null }, { @@ -217,7 +217,6 @@ }, { "cell_type": "code", - "outputs": [], "source": [ "from utils.visualize import visualize_materials as visualize\n", "\n", @@ -228,6 +227,7 @@ "collapsed": false }, "id": "45f0c424ece00186", + "outputs": [], "execution_count": null }, { @@ -243,22 +243,26 @@ }, { "cell_type": "code", - "outputs": [], "source": [ "from mat3ra.made.tools.modify import filter_by_condition_on_coordinates, add_vacuum\n", - "from mat3ra.made.tools.build.slab import create_slab, SlabConfiguration\n", + "from mat3ra.made.tools.analyze.lattice_planes import CrystalLatticePlanesMaterialAnalyzer\n", + "from mat3ra.made.tools.build.slab.helpers import create_slab\n", + "\n", + "# Create analyzer to get terminations\n", + "analyzer = CrystalLatticePlanesMaterialAnalyzer(material=material, miller_indices=MILLER_INDICES)\n", + "\n", + "# Get termination from analyzer\n", + "terminations = analyzer.terminations\n", + "termination = terminations[0] # Use first termination\n", "\n", - "slab_config = SlabConfiguration(\n", - " bulk=material,\n", + "slab_unit_cell = create_slab(\n", + " crystal=material,\n", + " termination=termination,\n", " miller_indices=MILLER_INDICES,\n", " number_of_layers=THICKNESS,\n", - " vacuum=0,\n", + " vacuum=VACUUM,\n", " xy_supercell_matrix=XY_SUPERCELL_MATRIX,\n", - " use_orthogonal_z=True,\n", - " use_conventional_cell=True,\n", ")\n", - "\n", - "slab_unit_cell = create_slab(slab_config)\n", "resulting_material = filter_by_condition_on_coordinates(slab_unit_cell, condition)\n", "resulting_material = add_vacuum(resulting_material, VACUUM)" ], @@ -266,6 +270,7 @@ "collapsed": false }, "id": "422815d29aa347a1", + "outputs": [], "execution_count": null }, { @@ -280,7 +285,6 @@ }, { "cell_type": "code", - "outputs": [], "source": [ "visualize(resulting_material, repetitions=[1, 1, 1], rotation=\"0x\")\n", "visualize(resulting_material, repetitions=[1, 1, 1], rotation=\"-90x\")\n", @@ -290,6 +294,7 @@ "collapsed": false }, "id": "2a9627cd4a261067", + "outputs": [], "execution_count": null }, { @@ -304,7 +309,6 @@ }, { "cell_type": "code", - "outputs": [], "source": [ "from utils.jupyterlite import set_materials\n", "\n", @@ -315,6 +319,7 @@ "collapsed": false }, "id": "cbee60d4b936e5cb", + "outputs": [], "execution_count": null } ], diff --git a/other/materials_designer/create_slab.ipynb b/other/materials_designer/create_slab.ipynb index bf6e8856..fde1ea3f 100644 --- a/other/materials_designer/create_slab.ipynb +++ b/other/materials_designer/create_slab.ipynb @@ -48,7 +48,7 @@ "THICKNESS = 3 # in atomic layers\n", "VACUUM = 10.0 # in angstroms\n", "XY_SUPERCELL_MATRIX = [[1, 0], [0, 1]]\n", - "USE_ORTHOGONAL_Z = True\n", + "USE_ORTHOGONAL_C = True\n", "USE_CONVENTIONAL_CELL = True\n", "\n", "# Index of the termination to be selected\n", @@ -146,8 +146,8 @@ "source": [ "## 2. Configure slab and select termination\n", "\n", - "### 2.1. Create slab configuration\n", - "Slab Configuration lets define the slab thickness, vacuum, and the Miller indices of the interfacial plane and get the slabs with possible terminations.\n" + "### 2.1. Create crystal lattice planes analyzer\n", + "CrystalLatticePlanesMaterialAnalyzer is used to analyze the crystal lattice planes of the material and determine possible terminations for the slab.\n" ], "metadata": { "collapsed": false @@ -155,23 +155,15 @@ "id": "6634dae92a6c07b9" }, { + "metadata": { + "collapsed": false + }, "cell_type": "code", "source": [ - "from mat3ra.made.tools.build.slab import SlabConfiguration\n", + "from mat3ra.made.tools.analyze.lattice_planes import CrystalLatticePlanesMaterialAnalyzer\n", "\n", - "slab_configuration = SlabConfiguration(\n", - " bulk=material,\n", - " miller_indices=MILLER_INDICES,\n", - " number_of_layers=THICKNESS, # in atomic layers\n", - " vacuum=VACUUM, # in angstroms\n", - " xy_supercell_matrix=XY_SUPERCELL_MATRIX,\n", - " use_orthogonal_z=USE_ORTHOGONAL_Z,\n", - " use_conventional_cell=USE_CONVENTIONAL_CELL,\n", - ")" + "analyzer = CrystalLatticePlanesMaterialAnalyzer(material=material, miller_indices=MILLER_INDICES)" ], - "metadata": { - "collapsed": false - }, "id": "3ad6765249610aa4", "outputs": [], "execution_count": null @@ -188,10 +180,7 @@ }, { "cell_type": "code", - "source": [ - "from mat3ra.made.tools.build.slab import get_terminations\n", - "slab_terminations = get_terminations(slab_configuration)" - ], + "source": "slab_terminations = analyzer.terminations", "metadata": { "collapsed": false }, @@ -212,11 +201,10 @@ { "cell_type": "code", "source": [ - "from mat3ra.made.tools.build.slab import create_slab\n", "\n", - "slabs = [create_slab(slab_configuration, termination) for termination in slab_terminations]\n", + "slabs = [analyzer.get_material_with_termination_without_vacuum(termination) for termination in slab_terminations]\n", "\n", - "visualize([{\"material\":slab, \"title\": slab.metadata[\"build\"][\"termination\"]} for slab in slabs ], repetitions=[3, 3, 1], rotation=\"-90x\")" + "visualize([{\"material\":slab, \"title\": slab.name} for slab in slabs ], repetitions=[3, 3, 1], rotation=\"-90x\")" ], "metadata": { "collapsed": false @@ -283,7 +271,9 @@ { "cell_type": "markdown", "source": [ - "## 3. Create the slab with selected termination" + "## 3. Create the slab with selected termination\n", + "\n", + "3.1. Create slab with specified termination" ], "metadata": { "collapsed": false @@ -293,9 +283,17 @@ { "cell_type": "code", "source": [ - "from mat3ra.made.tools.build.slab import create_slab\n", + "from mat3ra.made.tools.build.slab.helpers import create_slab\n", "\n", - "slab = create_slab(slab_configuration, termination)" + "slab = create_slab(crystal=material,\n", + " termination=termination,\n", + " use_conventional_cell=USE_CONVENTIONAL_CELL,\n", + " miller_indices=MILLER_INDICES,\n", + " number_of_layers= THICKNESS,\n", + " vacuum=VACUUM,\n", + " xy_supercell_matrix=XY_SUPERCELL_MATRIX,\n", + " use_orthogonal_c=USE_ORTHOGONAL_C,\n", + " )\n" ], "metadata": { "collapsed": false @@ -305,10 +303,26 @@ "execution_count": null }, { + "metadata": {}, "cell_type": "markdown", + "source": "### 3.2. Create slab supercell", + "id": "677536f3b6243679" + }, + { + "metadata": {}, + "cell_type": "code", "source": [ - "## 4. Visualize the slab" + "from mat3ra.made.tools.operations.core.unary import supercell\n", + "\n", + "slab_supercell = supercell(slab, XY_SUPERCELL_MATRIX)" ], + "id": "b67c1b26078499fd", + "outputs": [], + "execution_count": null + }, + { + "cell_type": "markdown", + "source": "## 4. Visualize the resulting slab", "metadata": { "collapsed": false }, @@ -316,9 +330,7 @@ }, { "cell_type": "code", - "source": [ - "visualize(slab, repetitions=[1, 1, 1], rotation=\"0x\")" - ], + "source": "visualize(slab_supercell, repetitions=[1, 1, 1], rotation=\"0x\")", "metadata": { "collapsed": false }, @@ -340,7 +352,7 @@ "cell_type": "code", "source": [ "from utils.jupyterlite import set_materials\n", - "set_materials(slab)" + "set_materials(slab_supercell)" ], "metadata": { "collapsed": false