flow 1.4.0
Kokkos cut-cell IBM incompressible Navier-Stokes solver + pnm pore extraction
Loading...
Searching...
No Matches
transient2.py
Go to the documentation of this file.
1"""smooth startup (forcing ramped by (1-cos)/2 over R steps): split vs implicit, new sharp and current arith."""
2import mac2d as M, numpy as np
3from stab import blocks, rho_face
4N = 24; R = 40
5def ops(case, target, kcellvol, kscheme):
6 if target == "sharp": M.SHARP_BASE, M.FCORR = "facef", "fit"; sch = "sharp"
7 else: M.SHARP_BASE, M.FCORR = "arith", None; sch = "arith"
8 Af, b, uidx, xall, m = M.build(case, sch, "fit"); M.FCORR = None
9 nv = len(uidx); Af = Af.toarray()
10 M.CELL_VOL = kcellvol; K = blocks(case, kscheme, "arith", None, {"xx", "yy", "yu", "xv"})[0]; M.CELL_VOL = False
11 return -Af[:nv, :nv], Af[:nv, nv:nv + N * N], Af[nv:nv + N * N, :nv], -b[:nv], K, uidx, m
12for (muA, rA) in ((1e-2, 1e-3), (1e-3, 1e-4), (1e2, 1e3)):
13 for (ang, off) in ((22.5, 0.3),):
14 case = M.Case(N, ang, off, muA, 1.0, "general")
15 for target, kcv, ks in (("sharp", True, "facef"), ("arith", False, "arith")):
16 At, G, D, F, K, uidx, m = ops(case, target, kcv, ks)
17 rf = rho_face(case, uidx, m, rA, 1.0)
18 out = []
19 for Dn in (0.1, 0.3, 1.0):
20 dt = Dn * case.h**2 * (1.0 if muA < 1 else rA / muA)
21 Mm = np.diag(rf / dt); Mi = np.diag(dt / rf)
22 P = np.eye(len(rf)) - Mi @ G @ np.linalg.pinv(D @ Mi @ G) @ D
23 Si = np.linalg.inv(Mm + At); Ss = np.linalg.inv(Mm + K)
24 ui = np.zeros(len(rf)); us = np.zeros(len(rf)); d = []
25 for n in range(1, 3 * R + 1):
26 Fn = F * 0.5 * (1 - np.cos(np.pi * min(n, R) / R))
27 ui = P @ (Si @ (Mm @ ui + Fn)); us = P @ (Ss @ (Mm @ us + (K - At) @ us + Fn))
28 d.append(np.max(np.abs(us - ui)) / np.max(np.abs(ui)))
29 out.append("D=%.1f: max %.1e, end %.1e" % (Dn, max(d), d[-1]))
30 print("muA/muB=%-5g %-5s split-vs-implicit:" % (muA, target), " | ".join(out))
ops(case, target, kcellvol, kscheme)
Definition transient2.py:5