forked from delemottelab/string-method-swarms-trajectories
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
75 lines (64 loc) · 2.5 KB
/
main.py
File metadata and controls
75 lines (64 loc) · 2.5 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import argparse
from stringmethod import *
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument(
"--config_file",
type=str,
help="A config file in JSON format",
default=None,
)
parser.add_argument(
"--iteration",
type=int,
help="Current iteration of the string method",
default=1,
)
parser.add_argument(
"--start_mode",
type=str,
help="starting_step (steered|string|postprocessing)",
default="string",
)
return parser.parse_args()
def run(conf: config.Config, start_mode, iteration=1) -> None:
logger.debug("Using config %s", conf)
if start_mode == "string":
r = stringmd.StringIterationRunner.from_config(
config=conf, iteration=iteration, append=start_mode == "auto"
)
r.run()
# return run(conf, start_mode='postprocessing')
elif start_mode == "steered":
r = steeredmd.SteeredRunner.from_config(config=conf)
r.run()
elif start_mode == "postprocessing":
postprocessing.run(conf)
else:
raise ValueError("Unknown start mode {}".format(start_mode))
if __name__ == "__main__":
try:
logger.info(
"""
.___ .__ __ __ .__ ___.
__| _/____ | | ____ _____ _____/ |__/ |_ ____ | | _____ \_ |__
/ __ |/ __ \| | _/ __ \ / \ / _ \ __\ __\/ __ \| | \__ \ | __ \
/ /_/ \ ___/| |_\ ___/| Y Y ( <_> ) | | | \ ___/| |__/ __ \| \_\ \
\____ |\___ >____/\___ >__|_| /\____/|__| |__| \___ >____(____ /___ /
\/ \/ \/ \/ \/ \/ \/
Starting string of swarms simulation by Oliver Fleetwood and Marko Petrovic 2017-2020.
https://github.com/delemottelab/string-method-gmxapi
Version {}
""".format(
VERSION
)
)
args = parse_args()
args.iteration = max(args.iteration, 1)
conf = config.load_config(args.config_file)
logger.setLevel(conf.log_level)
run(conf, args.start_mode, args.iteration)
logger.info("----------------Finished------------")
except Exception as ex:
logger.exception(ex)
logger.error("Script failed with message %s", str(ex))