-
Notifications
You must be signed in to change notification settings - Fork 0
/
rerun.py
57 lines (45 loc) · 1.37 KB
/
rerun.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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
rerun.py
Loads data from a previous run and evolves it again
Allows initializations to be changed!
"""
import time
from evolver.integrator import Driver, Status
from evolver.model import Model
import argparse
desc = "Reruns a previous run, possibly with changed parameters"
parser = argparse.ArgumentParser(description=desc)
parser.add_argument("filename", help="Parameters file to load (.params file)")
args = parser.parse_args()
# Load the model
model = Model.load(args.filename + ".params")
#
# If you want to modify any parameters, do it here
#
model.parameters['fulloutput'] = True
model.fulloutput = True
# Change the filename
filename = "data/newrun"
model.parameters['basefilename'] = filename
model.basefilename = filename
model.save(filename + ".params")
#
# Now do the run again
#
# Construct the driver
driver = Driver(model)
# Perform the evolution
print("Beginning evolution")
start = time.time()
driver.run()
end = time.time()
print("Finished in {} s".format(round(end - start, 4)))
# Check to see what our status is
if driver.status == Status.IntegrationError:
print("Unable to integrate further: {}".format(driver.error_msg))
elif driver.status == Status.Terminated:
print("Evolution completed with message: {}".format(driver.error_msg))
elif driver.status == Status.Finished:
print("Evolution completed!")