-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathread.py
34 lines (29 loc) · 917 Bytes
/
read.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
30
31
32
33
34
#!/usr/local/bin/python
import sys, os
sys.path += ["/g/g91/ogitsu/bin"]
from phys import *
confs = []
atoms = []
for file in sys.arg[1:]:
for line in open(file):
tmp = line.split()
if len(tmp) == 1:
numatom = int(tmp[0])
if len(atoms) > 0:
confs += [cell,atoms]
atoms = []
elif len(tmp) == 9:
(ax,ay,az,bx,by,bz,cx,cy,cz) = tmp
aa = D3v(float(ax),float(ay),float(az))
bb = D3v(float(bx),float(by),float(bz))
cc = D3v(float(cy),float(cy),float(cz))
cell = PeriodicCell(aa,bb,cc)
elif len(tmp) == 4:
(name,x,y,z) = tmp
r = D3v(float(x),float(y),float(z))
atoms += [{'element':name,'pos':r}]
for conf in confs:
cell = conf.pop(0)
for atoms in conf:
for atom in atoms:
print atom['element'],atom['pos']