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
3
usage: python post.py RUN_DIR [L=1.6]
4
log.dat columns: t ub umix uzm xcent vg step (units d = g = rho_l = 1; mu_l from err.log).
5
Re_drift = (ub - umix)/mu_l (Loisy eq. 2.3; run_case_a holds umix = 0, Basilisk does not),
6
Re_zm = (ub - uzm)/mu_l, Re_abs = ub/mu_l (computational frame). Windows as run_case_a.py: A = the
7
last two box crossings of the gas centroid measured in the <u> = 0 frame (x_rel = xcent - int umix dt),
8
B = the two before; trapezoidal time means. Re_cent = x_rel displacement over window A / time.
9
Prints one summary line."""
10
import
re
11
import
sys
12
13
import
numpy
as
np
14
15
d = sys.argv[1]
16
L = float(sys.argv[2])
if
len(sys.argv) > 2
else
1.6
17
hdr = open(f
"{d}/err.log"
).readline()
18
mu_l = float(re.search(
r"mu2 (\S+)"
, hdr).group(1))
19
N = int(re.search(
r"# N (\d+)"
, hdr).group(1))
20
H = np.loadtxt(f
"{d}/log.dat"
)
21
t, ub, um, uz, xc = H[:, 0], H[:, 1], H[:, 2], H[:, 3], H[:, 4]
22
cum = np.concatenate(([0.0], np.cumsum(0.5 * (um[1:] + um[:-1]) * np.diff(t))))
23
xr = xc - cum
24
cols = {
"drift"
: (ub - um) / mu_l,
"zm"
: (ub - uz) / mu_l,
"abs"
: ub / mu_l,
"umix"
: um / mu_l}
25
26
27
def
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
32
xe = xr[-1]
33
A = {k:
wmean
(v, xe, xe - 2 * L)
for
k, v
in
cols.items()}
34
B =
wmean
(cols[
"drift"
], xe - 2 * L, xe - 4 * L)
35
m = xr > xe - 2 * L
36
ta = t[m][0]
37
rc = (xe - xr[m][0]) / (t[-1] - ta) / mu_l
38
print(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}"
)
post.wmean
wmean(y, hi, lo)
Definition
post.py:27
tests
study
case_a
basilisk
post.py
Generated by
1.15.0