-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathmcnp_run_plot.py
More file actions
87 lines (71 loc) · 2.34 KB
/
mcnp_run_plot.py
File metadata and controls
87 lines (71 loc) · 2.34 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
76
77
78
79
80
81
82
83
84
85
86
87
"""
Reads to output dumped to screen and plots rendevous frequency etc
works on the output to std out from MCNP6
does not work on the MCNP output file
"""
import matplotlib as mpl
import matplotlib.pyplot as plt
import datetime
import argparse
import logging as ntlogger
import neut_utilities as ut
mpl.use('Agg')
def plot_nps_stats(path, fname=None):
""" reads std out file of mcnp run and produces graphs vs nps
these are useful for identifing any long history issues
process - read file, extract data, plot graphs
"""
ut.setup_ntlogger()
lines = ut.get_lines(path)
ctm = [] # computer time
nrn = [] # number random numbers
nps = [] # number source particles
coll = [] # number of collisions
time = [] # wall clock time
for line in lines:
if "ctm" in line:
ctm.append(float(line[6:18]))
nrn.append(int(line[26:44]))
if "dump" in line:
coll.append(int(line[61:78]))
if "master set rendezvous" in line:
nps.append(int(line[28:40]))
t1 = datetime.datetime.strptime(line[66:83], '%m/%d/%y %H:%M:%S')
time.append(t1)
time = mpl.dates.date2num(time)
fmt = mpl.dates.DateFormatter('%d/%m %H:%M')
fig = plt.figure()
ax = fig.add_subplot(221)
ax.xaxis.set_major_formatter(fmt)
ax.set_xlabel("time")
ax.set_ylabel("nps")
ax.plot(time, nps)
ax1 = fig.add_subplot(222)
ax1.set_xlabel("nps")
ax1.set_ylabel("ctm")
ax1.plot(nps, ctm[1:])
ax2 = fig.add_subplot(223)
ax2.set_xlabel("nps")
ax2.set_ylabel("nrn")
ax2.plot(nps, nrn[1:])
ax3 = fig.add_subplot(224)
ax3.set_xlabel("nps")
ax3.set_ylabel("coll")
ax3.plot(nps, coll[1:])
fig.tight_layout()
if fname:
plt.savefig(fname)
ntlogger.info("produced figure: %s", fname)
else:
plt.show()
if __name__ == "__main__":
desc = "data about run time and rendevous frequency"
parser = argparse.ArgumentParser(description=desc)
parser.add_argument("input", help="path to the input file")
parser.add_argument("-o", "--output", action="store", dest="output",
help="path to the output file")
args = parser.parse_args()
if args.output:
plot_nps_stats(args.input, args.output)
else:
plot_nps_stats(args.input)