-
-
Save simonbatzner/c2b05d38789b67f6fe5d3c75a4f2223d to your computer and use it in GitHub Desktop.
from ase.io import read, write | |
# outcar contanining one (single-point) or multiple (trajectory) DFT frames | |
in_filename = './OUTCAR' | |
out_filename = 'nequip-data.extxyz' | |
# read all frames into a list of ase.Atoms objects | |
all_atoms = read(in_filename, format='vasp-out', index=':') | |
for curr_atoms in enumerate(all_atoms): | |
write('out_filename', curr_atoms, append=True, format='extxyz') |
Hm, this worked for me in the past, and looking at the code here it does indeed iterate over frames:
@reader
def read_vasp_out(filename='OUTCAR', index=-1):
"""Import OUTCAR type file.
Reads unitcell, atom positions, energies, and forces from the OUTCAR file
and attempts to read constraints (if any) from CONTCAR/POSCAR, if present.
"""
# "filename" is actually a file-descriptor thanks to @reader
g = iread_vasp_out(filename, index=index)
# Code borrowed from formats.py:read
if isinstance(index, (slice, str)):
# Return list of atoms
return list(g)
else:
# Return single atoms object
return next(g)
Can I ask what is in 220.OUTCAR
, does it come from an AIMD simulation?
Hm, that seems more like a question for the ASE folks, I'm sorry I can't help you much here.
Unrelated to previous comments: there is a glitch in reading OUTCAR's with ase
if one (a) installs ase
with anaconda and (b) uses spin-polarized calculations in (c) VASP 6. It manifests as an AssertionError
. It can be fixed by taking vasp_outcar_parsers.py
from the ase
GitLab repo (tested 2022.12.02) and substituting that for the anaconda-installed one.
hello,
I replaced the vasp-out file,but still I am getting this error: ase.io.ParseError: Did not find required property positions during parse. My outcar files include positions but the script can not find any. thanks
This one works.
from ase.io import read, write
Read all frames from OUTCAR
atoms_list = read('OUTCAR', index=':')
Write all frames to a single EXTXYZ file
write('output.extxyz', atoms_list)
Hi, Thank you for the code
i don't think its taking into consideration all the frames (at least for me), i ran the code on a system with 390 atom and 37 frame, i confirmed that using dpdata package as follow:
but when i read the same file with ase.io.read i get the following:
normally this shouldn't be happening since index is settled to all (':') , maybe there is something that i'm not seeing it !
Can you help me with that please ?