-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
executable file
·61 lines (50 loc) · 1.31 KB
/
main.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
"""
This main script runs a simulation and saves the output to ./figures/
Example use case with animated output:
python main.py --num_iters 100 --plot 1
Example use case without animated output:
python main.py --num_iters 100 --plot 0
"""
import argparse
import os
import time
import matplotlib.pyplot as plt
import CAAF.model as model
parser = argparse.ArgumentParser()
parser.add_argument(
"-n",
"--num_iters",
help="number of iterations to run the model",
type=int,
required=True,
)
parser.add_argument(
"-p",
"--plot",
help="saves animation of simulation in a .mp4 file",
type=int,
default=0,
)
args = parser.parse_args()
num_iters = args.num_iters
plot = args.plot
parameters = {
"row_size": 200,
"col_size": 200,
"refractory_period": 50,
"driving_period": 220,
"prob_not_fire": 0.05,
"prob_con": 0.09,
"prob_def": 0.05,
}
if __name__ == "__main__":
heart = model.Heart(**parameters)
os.makedirs('figures', exist_ok=True)
start_time = time.time()
heart.update(num_iters=num_iters, plot=plot)
duration = time.time() - start_time
print("Time: {0} s".format(duration))
# Number of active cells with time
fig, ax = plt.subplots(figsize=[5, 5])
ax.plot(heart.num_active_cells)
fig.savefig("./figures/num_active_cells.png")