[comparator] extract elasped time from coarse step

This commit is contained in:
Noe Brucy
2021-05-06 15:10:27 +02:00
parent 6a998abccd
commit 9c28f5212a
2 changed files with 67 additions and 26 deletions
+42 -11
View File
@@ -267,24 +267,37 @@ class Comparator(Aggregator, HDF5Container):
series["fine_step"][run].append(fine_step)
series["dt"][run].append(dt)
series["a"][run].append(a)
series["mempc1"][run].append(mempc1)
series["mempc2"][run].append(mempc2)
series["mem_cells"][run].append(mempc1)
series["mem_parts"][run].append(mempc2)
return series
def _extract_coarse_step_from_log(self, series, log_filename, run):
rism = self.pp_params.input.ramses_ism
nlines = 2 + int(rism) # Number of useful lines
cmd_grep = "grep 'Main step' {} -A {}".format(log_filename, nlines - 1)
cmd_grep = "grep 'Main step\\|coarse step' {} -A {}".format(
log_filename, nlines - 1
)
content = os.popen(cmd_grep).readlines()
for i in range(0, len(content), nlines + 1):
for j in range(0, len(content), 2 * (nlines + 1)):
i = j + nlines + 1 # Index for the "Main step" grep
if i + nlines - 1 < len(content):
series["time"][run].append(
np.float(content[i + nlines - 1].split("=")[2].split()[0])
)
series["step"][run].append(np.int(content[i].split("=")[1].split()[0]))
series["mcons"][run].append(np.float(content[i].split("=")[2].split()[0]))
series["econs"][run].append(np.float(content[i].split("=")[3].split()[0]))
series["epot"][run].append(np.float(content[i].split("=")[4].split()[0]))
series["ekin"][run].append(np.float(content[i].split("=")[5].split()[0]))
series["mcons"][run].append(
np.float(content[i].split("=")[2].split()[0])
)
series["econs"][run].append(
np.float(content[i].split("=")[3].split()[0])
)
series["epot"][run].append(
np.float(content[i].split("=")[4].split()[0])
)
series["ekin"][run].append(
np.float(content[i].split("=")[5].split()[0])
)
if rism:
eint = np.float(content[i].split("=")[6].split()[0])
emag = np.float(content[i + 1].split("=")[1].split()[0])
@@ -293,6 +306,11 @@ class Comparator(Aggregator, HDF5Container):
emag = 0.0
series["eint"][run].append(eint)
series["emag"][run].append(emag)
series["elapsed"][run].append(
np.float(content[j].split(":")[1].split()[0])
)
series["memory"][run].append(content[j + 1].split(":")[1])
return series
def _extract_rms_from_log(self, series, log_filename, run):
@@ -580,7 +598,18 @@ class Comparator(Aggregator, HDF5Container):
self,
partial(
self._from_log,
["time", "step", "mcons", "econs", "epot", "ekin", "eint", "emag"],
[
"time",
"step",
"mcons",
"econs",
"epot",
"ekin",
"eint",
"emag",
"elapsed",
"memory",
],
self._extract_coarse_step_from_log,
),
group="/series",
@@ -593,6 +622,8 @@ class Comparator(Aggregator, HDF5Container):
"ekin": U.none,
"eint": U.none,
"emag": U.none,
"elapsed": U.s,
"memory": U.none,
},
),
"fine_step_from_log": Rule(
@@ -608,8 +639,8 @@ class Comparator(Aggregator, HDF5Container):
"fine_step": U.none,
"dt": "unit_time",
"a": U.none,
"mempc1": U.none,
"mempc2": U.none,
"mem_cells": U.none,
"mem_parts": U.none,
},
),
"turb_power": Rule(
+13 -3
View File
@@ -196,6 +196,7 @@ class Plotter(Aggregator, BaseProcessor):
nml = self.comp.namelist[run]
name = simu_fmt.format(run=run, tag=tag, nml=nml)
exec_time = str(datetime.datetime.fromtimestamp(os.stat(pp.path).st_ctime))
exec_time = exec_time.split(".")[0]
description = descr_fmt.format(run=run, tag=tag, nml=nml)
simu = Simulation(
simu_code=ramses,
@@ -1739,12 +1740,21 @@ class Plotter(Aggregator, BaseProcessor):
dependencies=[group],
)
for name in ["step", "mcons", "econs", "epot", "ekin", "eint", "emag"]:
for name in [
"step",
"mcons",
"econs",
"epot",
"ekin",
"eint",
"emag",
"elapsed",
]:
self._gen_from_log("coarse_step_from_log", name)
for name in ["fine_step", "dt", "a", "mempc1", "mempc2"]:
for name in ["fine_step", "dt", "a", "mem_cells", "mem_parts"]:
self._gen_from_log("fine_step_from_log", name)
for name in ["time", "dt", "a", "mempc1", "mempc2"]:
for name in ["time", "dt", "a", "mem_cells", "mem_parts"]:
self._gen_from_log("fine_step_from_log", name_y=name, name_x="fine_step")
# Dict of overlays