{ "cells": [ { "cell_type": "markdown", "id": "9e1230c8", "metadata": {}, "source": [ "# Vector Field\n", "\n", "The vector field is defined by the origins and vectors, and it is visualized by the arrows. The vector field is useful for visualizing the magnetic moment, phonon visualization, etc.\n", "\n", "\n", "## Magentic moment visualization\n", "Show the magnetic moment as a vector field." ] }, { "cell_type": "code", "execution_count": null, "id": "a54f358b", "metadata": {}, "outputs": [], "source": [ "from ase.build import bulk\n", "from weas_widget import WeasWidget\n", "import numpy as np\n", "atoms = bulk(\"Fe\", cubic=True)\n", "atoms*=[2, 2, 1]\n", "atoms.set_array(\"moment\", np.ones(len(atoms)))\n", "viewer = WeasWidget()\n", "viewer.from_ase(atoms)\n", "viewer.avr.model_style = 1\n", "viewer" ] }, { "cell_type": "markdown", "id": "9accaed9", "metadata": {}, "source": [ "## Interactive phonon visualization\n", "One can visualize the phonon dispersion via lattice vibrations. One only need to use the eigenstates (calculated with an external software) to generate the trajectory. Each eigenvector should has the real and imaginary part. One can also specify the kpoint, amplitude, nframes, repeat, color, and radius.\n" ] }, { "cell_type": "code", "execution_count": null, "id": "ad7535b0", "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "from ase.build import bulk\n", "from weas_widget import WeasWidget\n", "atoms = bulk(\"Fe\", cubic=True)\n", "phonon_setting = {\"eigenvectors\": np.array([[[0, 0], [0, 0],[0.5, 0]],\n", " [[0, 0], [0, 0], [-0.5, 0]]]\n", " ),\n", " \"kpoint\": [0, 0, 0], # optional\n", " \"amplitude\": 5, # scale the motion of the atoms\n", " \"factor\": 1.5, # scale the length of the arrows\n", " \"nframes\": 20,\n", " \"repeat\": [4, 4, 1],\n", " \"color\": \"blue\",\n", " \"radius\": 0.1,\n", " }\n", "viewer = WeasWidget()\n", "viewer.from_ase(atoms)\n", "viewer.avr.phonon_setting = phonon_setting\n", "viewer" ] } ], "metadata": { "language_info": { "name": "python" } }, "nbformat": 4, "nbformat_minor": 5 }