ASE convesion of Trajectory file to XDATCAR

The issue here is while converting a TRAJ file to POSCAR, it works. But, for TRAJ to XDATCAR, it shows

TypeError: images should be a sequence of Atoms objects

. (Check below to see the error report)

import ase
from ase.io import read, write
from ase.io.vasp import write_vasp_xdatcar

bec = ase.io.read("./run10/local_minima.traj")
bec_new_pos = ase.io.vasp.write_vasp("local_minima_new.poscar", bec, vasp5=True)
bec_new_xdat = ase.io.vasp.write_vasp_xdatcar("local_minima_new.xdatcar", bec, label=None)

Hi Saha,

To convert a trajectory in an XDATCAR, you need to read the traj file using the Trajectory function in ASE. Note that the xdatcar writer will not work if your traj contains only one structure. Also, the read function by default only reads the last structure in the traj file.

import ase
from ase.io.trajectory import Trajectory
from ase.io import read, write
from ase.io.vasp import write_vasp_xdatcar

bec =  Trajectory("./run10/local_minima.traj")
bec_new_xdat = write_vasp_xdatcar("local_minima_new.xdatcar", bec, label=None)