forked from MiaoLab20/gamd-openmm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gamdRunner
executable file
·83 lines (70 loc) · 3.49 KB
/
gamdRunner
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
#!/usr/bin/env python
"""
This runner program ties together the different components and
provides a command line interface to run basic GaMD simulations
under OpenMM.
"""
import argparse
from gamd import gamdSimulation
from gamd import parser
from gamd.runners import Runner
def main():
argparser = argparse.ArgumentParser(description=__doc__)
argparser.add_argument(
"input_file_type", metavar="INPUT_FILE_TYPE", type=str,
help="The type of file being provided. Available options are: 'xml', "
"... More to come later")
argparser.add_argument(
"input_file", metavar="INPUT_FILE", type=str,
help="name of input file for GaMD calculation. only XML format is "
"currently preferred.")
argparser.add_argument("-r", "--restart", dest="restart", default=False,
help="Restart simulation from backup checkpoint in "
"input file", action="store_true")
argparser.add_argument("-p", "--platform", dest="platform", default="CUDA",
help="Define the platform that will run the "
"simulations. Default is 'CUDA', but other "
"options include: 'Reference', 'CPU', and "
"'OpenCL'.",
type=str)
argparser.add_argument("-d", "--device_index", dest="device_index",
default="0",
help="modify which device_index to run the "
"simulation on. For example, the number 0 or "
"1 would suffice. To run on multiple GPU "
"indices, simply enter comma separated "
"indices. Example: '0,1'. If a value is not "
"supplied, the value '0' will be used by "
"default.", type=str)
argparser.add_argument("-D", "--debug", dest="debug", default=False,
help="Whether to start the run in debug mode.",
action="store_true")
argparser.add_argument("-o", "--output", dest="output_directory",
default=False,
help="Provides the capability to override the "
"configuration value in your configuration "
"for the output directory.",
type=str)
args = argparser.parse_args() # parse the args into a dictionary
args = vars(args)
config_file_type = args["input_file_type"]
config_filename = args["input_file"]
restart = args["restart"]
platform = args["platform"]
device_index = args["device_index"]
debug = args["debug"]
parserFactory = parser.ParserFactory()
config = parserFactory.parse_file(config_filename, config_file_type)
if ("output_directory" in args and
args["output_directory"] is not None and
args["output_directory"] is not False and
args["output_directory"].strip()):
config.outputs.directory = args["output_directory"]
gamdSimulationFactory = gamdSimulation.GamdSimulationFactory()
gamdSim = gamdSimulationFactory.createGamdSimulation(
config, platform, device_index)
# If desired, modify OpenMM objects in gamdSimulation object here...
runner = Runner(config, gamdSim, debug)
runner.run(restart)
if __name__ == "__main__":
main()