{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Finding the MSD uncertainties from a VASP file\n", "\n", "Using ``kinisi`` to obtain the mean-squared displacement and uncertainty in a VASP Xdatcar type file is straightforward and involves using the `DiffusionAnalyzer` class." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "from kinisi.analyze import DiffusionAnalyzer\n", "np.random.seed(1)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "There the `params` dictionary describes details about the simulation, and are fully documented in the [parser module](./parser.html).\n", "The `'specie'` is the atomic/ionic species that you want to calculate the MSD for, the `'time_step'` is the simulation timestep in your molecular dynamics, and the `'step_skip'` is the frequency which with the data was written in your simulation trajectory." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "params = {'specie': 'Li',\n", " 'time_step': 2.0,\n", " 'step_skip': 50}" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Therefore, for this example, we have a simulation that had a timestep of 2 femtoseconds (note the [FAQs about units](https://kinisi.readthedocs.io/en/latest/faq.html)) but we only stored the trajectory information every 50 steps and we want to investigate only the lithium motion. " ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "msd = DiffusionAnalyzer.from_file('example_XDATCAR.gz', parser_params=params)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The `DiffusionAnalyzer` will perform the bootstrapping process to obtain the displacements and uncertainties (this is detailed in the [methodology](./methodology.html). \n", "To find out how to determine the diffusion coefficient with `DiffusionAnalyzer` continue [here](https://kinisi.readthedocs.io/en/latest/vasp_d.html). \n", "\n", "Then the MSD (`msd`) as a function of timestep (`dt`) can be plotted." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import matplotlib.pyplot as plt" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "plt.errorbar(msd.dt, msd.msd, msd.msd_std)\n", "plt.ylabel('MSD/Å$^2$')\n", "plt.xlabel('$\\Delta t$/ps')\n", "plt.show()" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.7" } }, "nbformat": 4, "nbformat_minor": 4 }