flow 1.4.0
Kokkos cut-cell IBM incompressible Navier-Stokes solver + pnm pore extraction
Loading...
Searching...
No Matches
post.py
Go to the documentation of this file.
1"""Post-process a Basilisk case-A run (array.c) with run_case_a.py's definitions.
2
3usage: python post.py RUN_DIR [L=1.6]
4log.dat columns: t ub umix uzm xcent vg step (units d = g = rho_l = 1; mu_l from err.log).
5Re_drift = (ub - umix)/mu_l (Loisy eq. 2.3; run_case_a holds umix = 0, Basilisk does not),
6Re_zm = (ub - uzm)/mu_l, Re_abs = ub/mu_l (computational frame). Windows as run_case_a.py: A = the
7last two box crossings of the gas centroid measured in the <u> = 0 frame (x_rel = xcent - int umix dt),
8B = the two before; trapezoidal time means. Re_cent = x_rel displacement over window A / time.
9Prints one summary line."""
10import re
11import sys
12
13import numpy as np
14
15d = sys.argv[1]
16L = float(sys.argv[2]) if len(sys.argv) > 2 else 1.6
17hdr = open(f"{d}/err.log").readline()
18mu_l = float(re.search(r"mu2 (\S+)", hdr).group(1))
19N = int(re.search(r"# N (\d+)", hdr).group(1))
20H = np.loadtxt(f"{d}/log.dat")
21t, ub, um, uz, xc = H[:, 0], H[:, 1], H[:, 2], H[:, 3], H[:, 4]
22cum = np.concatenate(([0.0], np.cumsum(0.5 * (um[1:] + um[:-1]) * np.diff(t))))
23xr = xc - cum
24cols = {"drift": (ub - um) / mu_l, "zm": (ub - uz) / mu_l, "abs": ub / mu_l, "umix": um / mu_l}
25
26
27def wmean(y, hi, lo):
28 m = (xr > lo) & (xr <= hi)
29 return float(np.trapezoid(y[m], t[m]) / (t[m][-1] - t[m][0])) if m.sum() >= 2 else float("nan")
30
31
32xe = xr[-1]
33A = {k: wmean(v, xe, xe - 2 * L) for k, v in cols.items()}
34B = wmean(cols["drift"], xe - 2 * L, xe - 4 * L)
35m = xr > xe - 2 * L
36ta = t[m][0]
37rc = (xe - xr[m][0]) / (t[-1] - ta) / mu_l
38print(f"BASILISK N={N} d/h={N / L:g} t_end={t[-1]:.3f} steps={int(H[-1, 6])} Re_drift(2L)={A['drift']:.4f} "
39 f"[min {cols['drift'][m].min():.3f} max {cols['drift'][m].max():.3f}] Re_cent={rc:.4f} "
40 f"Re_zm={A['zm']:.4f} Re_abs={A['abs']:.4f} <u>/(nu/d)={A['umix']:.4f} "
41 f"dRe/Re(2L vs prev 2L)={abs(A['drift'] - B) / A['drift']:.2e} window t*=[{ta:.2f},{t[-1]:.2f}] "
42 f"vol_err={H[-1, 5] / H[0, 5] - 1:.1e}")
wmean(y, hi, lo)
Definition post.py:27