I want to convert the OUTCAR file to a file of xyz (not extxyz) format.
The informaiton of lattice (or cell) is stored in the comment line (like extxyz format).
Can this be done with the help of ase ?
Thanks.
Matter Modeling Stack Exchange is a question and answer site for materials modelers and data scientists. It only takes a minute to sign up.
Sign up to join this communityYou can do this by writing an ".extxyz" file but forcing the name to be ".xyz". In this way, the cell information is stored as comment. To remove the extra columns, you need to specify write_results=False
.
from ase.io import read, write
atoms = read('OUTCAR')
write('structure.xyz', atoms, format='extxyz', write_results=False)
Note that ase.io.write
writes to an ".extxyz" file by default, no matter you specify the filename to be ".xyz" or ".extxyz". So you will get the same result simply by
write('structure.xyz', atoms, write_results=False)
It only writes to a plain ".xyz" file if you do ase.io.xyz.write_xyz()
or ase.io.write(..., format='xyz')