{ "cells": [ { "cell_type": "markdown", "id": "fd7f75af", "metadata": {}, "source": [ "# Lattice plane\n", "\n", "The lattice plane is a plane that intersects the lattice. It is useful to visualize the lattice plane in the crystal structure.\n", "\n", "## Plane form miller indices\n", "The lattice plane can be defined by the miller indices and distance from the origin or by selecting the atoms.\n", "\n", "Here is an example of how to visualize lattice planes (111):\n" ] }, { "cell_type": "code", "execution_count": null, "id": "2f96ec91", "metadata": {}, "outputs": [], "source": [ "from ase.build import bulk\n", "from weas_widget import WeasWidget\n", "import numpy as np\n", "atoms = bulk(\"Au\", cubic=True)\n", "viewer = WeasWidget()\n", "viewer.from_ase(atoms)\n", "viewer.avr.model_style = 1\n", "viewer.camera.setting = {\"direction\": [0, -0.2, 1], \"zoom\": 0.8}\n", "# color is defined by RGBA, where R is red, G is green, B is blue, and A is the transparency\n", "viewer.avr.lp.add_plane_from_indices(name = \"111\",\n", " indices = [1, 1, 1],\n", " distance = 4,\n", " scale = 1.0,\n", " color = [0, 1, 1, 0.5])\n", "viewer.avr.lp.build_plane()\n", "viewer" ] }, { "cell_type": "markdown", "id": "23c9938f", "metadata": {}, "source": [ "## Plane from selected atoms\n", "One can also draw a plane from the selected atoms. Here is an example:\n" ] }, { "cell_type": "code", "execution_count": null, "id": "07243423", "metadata": {}, "outputs": [], "source": [ "from ase.build import bulk\n", "from weas_widget import WeasWidget\n", "import numpy as np\n", "atoms = bulk(\"Au\", cubic=True)\n", "viewer = WeasWidget()\n", "viewer.from_ase(atoms)\n", "viewer.avr.model_style = 1\n", "viewer.avr.selected_atoms_indices=[0, 1, 2]\n", "viewer.avr.lp.add_plane_from_selected_atoms(name = \"plane1\",\n", " color = [1, 0, 0, 0.5])\n", "viewer.avr.lp.build_plane()\n", "viewer" ] } ], "metadata": { "language_info": { "name": "python" } }, "nbformat": 4, "nbformat_minor": 5 }