-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsplit_init.py
More file actions
65 lines (53 loc) · 1.49 KB
/
Copy pathsplit_init.py
File metadata and controls
65 lines (53 loc) · 1.49 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
ff = open("initconds","r")
file = ff.readlines()
ff.close()
# unit convert
BOHR_2_ANG = 0.529177
# Get Atom and Temp.
for line in file:
if "Natom" in line:
natom = int(line.split()[-1])
if "Temp" in line:
temp = float(line.split()[-1])
print("Number of Atoms:",natom)
print("Temperature Ensemble [K]:",temp)
# Read geom and velocs
read = False
code = -1
for ii in range(len(file)):
line = file[ii]
if "Equilibrium" in line:
read = True
code = 0
continue
elif "Index" in line:
read = True
code = int(line.split()[-1])
continue
if "Atoms" in line:
continue
if read:
# Open output files
nameX = "geom_" + str(code)
nameXYZ = "geom_" + str(code) + ".xyz"
nameV = "veloc_" + str(code)
fx = open(nameX,"w")
fxyz = open(nameXYZ, "w")
fv = open(nameV,"w")
fxyz.write("%i\n" % natom)
fxyz.write("\n")
for jj in range(natom):
idx = ii + jj
line = file[idx].split()
output = " ".join(line[:6]) + "\n"
fx.write(output)
output = " ".join(line[6:]) + "\n"
fv.write(output)
x = float(line[2]) * BOHR_2_ANG
y = float(line[3]) * BOHR_2_ANG
z = float(line[4]) * BOHR_2_ANG
arr = [line[0],str(x),str(y),str(z)]
output = " ".join(arr) + "\n"
fxyz.write(output)
read = False
ii += natom