forked from Angel-Jia/VASP-script
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vas2xyz.py
29 lines (24 loc) · 913 Bytes
/
vas2xyz.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/env python3
import sys
from VASP import readVasp
from VASP import writeXYZ
if len(sys.argv) == 1:
print('')
print('Usage: %s vasp_file1 vasp_file2 ...' % sys.argv[0].split('/')[-1])
print('')
exit(1)
print('')
print("############### This script converts vasp file into .xyz file ###############")
print(" ############ CONTCAR or POSCAR -> .xyz ############")
print('')
for vasp_file in sys.argv[1:]:
print(' Processing %s' % vasp_file)
lattice, basis, elements, num_atoms, selectiveflag, coordinate_type, coordinates, selective = readVasp(vasp_file)
if vasp_file.endswith('.vasp'):
vasp_file = '%s.xyz' % vasp_file[:-5]
else:
vasp_file = '%s.xyz' % vasp_file
writeXYZ(vasp_file, 1, elements, num_atoms, coordinates)
print('')
print(" --------------------- DONE ---------------------\n")
print('')