-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdriver.py
71 lines (46 loc) · 1.73 KB
/
driver.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
import os
import argparse
from subprocess import Popen, PIPE
gmx='/usr/local/gromacs/bin/gmx'
def run_grompp (**kwargs):
os.makedirs ("Lambda_"+str(kwargs['l']),exist_ok=True)
proc = Popen([gmx,"grompp","-f",kwargs['f'],\
'-c',kwargs['c'],'-p',kwargs['p'],\
'-o',kwargs['o']], stdout=PIPE,\
stderr=PIPE, universal_newlines=True)
outs, errs = proc.communicate(timeout=15)
return outs
def run_mdrun (sim, input_file,n):
out_dir = sim + os.sep + "out"
log_dir = sim + os.sep + "log"
gro_dir = sim + os.sep + "gro"
cpo_dir = sim + os.sep + "cpi"
os.makedirs(out_dir, exist_ok=True)
os.makedirs(log_dir, exist_ok=True)
os.makedirs(gro_dir, exist_ok=True)
os.makedirs(cpo_dir, exist_ok=True)
#os.chdir(sim)
proc = Popen([gmx,"mdrun","-s",\
input_file,'-o',out_dir,'-g',log_dir,'-c',gro_dir,'-cpo',cpo_dir],\
stdout=PIPE, stderr=PIPE, universal_newlines=True)
outs, errs = proc.communicate(timeout=15)
return outs
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument ('-i','--input-mdp',help='Input mdp file')
parser.add_argument ('-n','--num-lambdas',type=int, help='Number of lambdas')
parser.add_argument ('-w','--work-dir',help='Workspace directory')
args = parser.parse_args()
kwargs = {}
case = "em_steep"
for l in range(0, 10):
tpr_file= case + os.sep + "min"+str(l)+".tpr"
kwargs['f'] = case+ os.sep + case +"_"+str(l)+".mdp"
kwargs['c'] = "config_files/methane_water.gro"
kwargs['p'] = "config_files/topol.top"
kwargs['o'] = tpr_file
kwargs['l'] = l
outs = run_grompp (**kwargs)
#print(outs)
run_mdrun (case, tpr_file, 4)
print(outs)