# Finding the MSD uncertainties from a VASP file#

Using kinisi to obtain the mean-squared displacement and uncertainty in a VASP Xdatcar type file is straightforward and involves using the DiffusionAnalyzer class.

[1]:

import numpy as np
from kinisi.analyze import DiffusionAnalyzer
np.random.seed(1)


There the params dictionary describes details about the simulation, and are documented in the parser module.

[2]:

params = {'specie': 'Li',
'time_step': 2.0,
'step_skip': 50,
'min_obs': 50}

[3]:

msd = DiffusionAnalyzer.from_file('example_XDATCAR.gz', parser_params=params)

Reading Trajectory: 100%|██████████| 140/140 [00:00<00:00, 3346.09it/s]
Getting Displacements: 100%|██████████| 139/139 [00:00<00:00, 17743.81it/s]
Bootstrapping Displacements:  87%|████████▋ | 121/139 [00:16<00:01, 12.06it/s]/home/docs/checkouts/readthedocs.org/user_builds/kinisi/envs/latest/lib/python3.7/site-packages/kinisi-0.3.10-py3.7.egg/kinisi/diffusion.py:244: UserWarning: The maximum number of resamples has been reached, and the distribution is not yet normal.
warnings.warn("The maximum number of resamples has been reached, and the distribution is not yet normal.")
Bootstrapping Displacements: 100%|██████████| 139/139 [00:19<00:00,  7.01it/s]


The DiffusionAnalyzer will perform the bootstrapping process to obtain the displacements and uncertainties (this is detailed in the methodology. To find out how to determine the diffusion coefficient with DiffusionAnalyzer continue here.

Then the MSD (msd) as a function of timestep (dt) can be plotted.

[4]:

import matplotlib.pyplot as plt

[5]:

plt.errorbar(msd.dt, msd.msd, msd.msd_std)
plt.ylabel('MSD/Å$^2$')
plt.xlabel('$\Delta t$/ps')
plt.show()