-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsi-paths.py
100 lines (81 loc) · 3.37 KB
/
si-paths.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
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
import os, subprocess, time
import pylada.crystal.read as pcread
from pmpaths import get_options, test_enum
from anim import anim_main
def wait_til_done(procs):
sleep_time = 30
done = False
while not done:
time.sleep(sleep_time)
done = True
for p in procs:
done = done and p.poll() != None
if __name__=="__main__":
options, arg = get_options()
direct = False
run_pmpaths = True
run_anim = True
pre = "POSCAR_"
post = ".cif"
dir = "geometry/SiO2/"
tdir = "trajSi"
## deleted:"Coesite",
poscars = ["Quartz_a", "Quartz_b", "Tridymite_a",
"Tridymite_b", "Cristobalite_a", "Cristobalite_b", "Moganite",
"Stishovite" ]
procs = []
a2 = []
fnames = []
for i in range(len(poscars)-1):
for j in range(len(poscars)):
options.A = os.path.join(dir, "%s%s%s" % (pre,poscars[i],post))
options.B = os.path.join(dir, "%s%s%s" % (pre,poscars[j],post))
options.trajdir = os.path.join(tdir, "%s-to-%s" % (poscars[i], poscars[j]))
if (direct):
A = pcread.poscar(options.A)
B = pcread.poscar(options.B)
test_enum(A,B,options)
anim_main(options)
else:
args = ["python", "pmpaths.py", "-t", "1", "-b", "2.0", "-z", options.trajdir, "-n", "231", "-A", options.A, "-B", options.B]
if (run_pmpaths):
stdout = file("stdout.%s-to-%s" % (poscars[i], poscars[j]), "w")
print "starting pmpaths with" , args
procs.append(subprocess.Popen(args, stdout = stdout))
# this just fires up the actual searches
args2 = ["python", "anim.py", "-e", "2e-1", "-z", options.trajdir, "-n", "21", "-A", options.A, "-B", options.B]
std2 = "stdout.anim.%s-to-%s" % (poscars[i], poscars[j])
a2.append(args2)
fnames.append(std2)
if (not direct):
p2 = []
if (not run_anim):
wait_til_done(procs)
elif (not run_pmpaths):
for i in range(len(procs)):
args = a2[i]
stdout = file(fnames[i], "w")
print "starting anim with" , args
p2.append(subprocess.Popen(args, stdout = stdout))
else:
# now anim part, launch each one after corresponding proc is done
sleep_time = 10
done = False
anim_running = [False for i in range(len(procs))]
while not done:
time.sleep(sleep_time)
for i in range(len(procs)):
if (not anim_running[i]):
p = procs[i]
# p.poll() != None means process is finished
done = p.poll() != None
if (done):
args = a2[i]
stdout = file(fnames[i], "w")
print "starting anim with" , args
p2.append(subprocess.Popen(args, stdout = stdout))
anim_running[i] = True
print anim_running
done = all(anim_running)
# wait til done so (on compute nodes) the job doesn't get killed
wait_til_done(p2)