top of page

Visualize XDATCAR Using Material Studio



The VASP output file, XDATCAR, contains the ionic configuration of the system after a specified number of ionic steps. This file is particularly useful for visualizing structural changes during ab initio molecular dynamic (AIMD) simulations or structural relaxation processes.


Several tools, such as JMOL and OVITO, can be employed to visualize the XDATCAR file. However, Material Studio, one of the most powerful visualization software, unfortunately does not support the XDATCAR format. In order to enable XDATCAR visualization in Material Studio, it is necessary to convert the file to a format that is supported by Material Studio, such as the .arc format.


I have provided the code below for converting XDATCAR to .arc format. Prior to using it, please ensure that you have xdat2xyz.pl and pos2xyz.pl in your $PATH directory (e.g., ~/bin/). These files can be downloaded from http://theory.cm.utexas.edu/code/vtstscripts.tgz. I have also attached them here for your convenience.


#!/bin/bash
################################################
# Transfer XDATCAR to movie.arc
# By Xijun Wang from Northwestern
# Email: wangxijun1016@gmail.com
################################################
xdat2xyz.pl
pos2cif.pl POSCAR
atom_number=`sed -n '7p' XDATCAR | awk '{ for(i=1;i<=NF;i++) sum+=$i; print sum}'`
step=`grep "Direct configuration=" XDATCAR | tail -1 | awk '{print $NF}'`
lattice_constant=`cat POSCAR.cif |grep _cell_|head -6|awk '{print $2}'|xargs|awk '{printf "PBC    %2.5f    %2.5f   %2.5f   %2.5f   %2.5f  %2.5f\n",$1,$2,$3,$4,$5,$6}'`

echo "!BIOSYM archive 3" > movie.arc
echo "PBC=ON" >> movie.arc

for x in `seq 1 $step`
do
echo $x
echo "     React      0          $x" >> movie.arc
echo "!DATE" >> movie.arc
echo $lattice_constant >> movie.arc
a=`echo $x $atom_number|awk '{print $1*($2+2)-($2-1)}'`
b=`echo $a $atom_number|awk '{print $1+$2-1}'`
sed -n "${a},${b}p" movie.xyz > xdatcar_to_arc.tmp
#cat xdatcar_to_arc.tmp|awk '{printf "%s",$1}' > element.tmp

seq 1 $atom_number > xdatcar_to_arc.tmp2
paste xdatcar_to_arc.tmp xdatcar_to_arc.tmp2 > xdatcar_to_arc.tmp3

cat xdatcar_to_arc.tmp3|awk '{printf "%s%18.9f%15.9f%15.9f CORE%5.0f      %s      %s %f\n",$1,$2,$3,$4,$5,$1,$1,$5}' >> movie.arc


echo "end" >> movie.arc
echo "end" >> movie.arc
done

The .arc file can be loaded directly in Material Studio, and can be converted into .avi by File - Export. The .avi can be furture converted to other formats like .gjf at https://cloudconvert.com/.


 

If you found this tutorial helpful, consider joining our community by making a donation. Your support will enable me to continue creating valuable content while also supporting my baby's care. Together, we can make a meaningful impact. Thank you!


185 views
bottom of page