pnm 1.0.3
peclet.pnm — pore-network extraction from SDF geometry (Kokkos)
Loading...
Searching...
No Matches
verify_network_flow.py
Go to the documentation of this file.
1"""Quantitative validation of pnm.extract_network_flow against a peclet.flow DNS.
2
3Geometry: a periodic chamber-tube chain — two spherical chambers connected by a straight
4cylindrical tube along x (also through the periodic boundary). The watershed segments this into
54 pores (2 chambers + 2 tube segments) in a single loop, so by mass conservation EVERY pore-pore
6throat must carry the full DNS flux F (measured independently as the openness-weighted x-flux
7through a grid plane). Checks:
8 1. per-pore residual (signed flux over the whole pore boundary) ~ solver tolerance,
9 2. |Q_throat| == F for every throat (small leakage through near-wall faces allowed),
10 3. Q and the total-pressure drop dp agree in sign on every throat (g = Q/dp > 0),
11 4. the DNS plane flux is x-independent (steady, converged).
12
13Run: PYTHONPATH=<pnm/build>:<flow/build> python scripts/verify_network_flow.py
14"""
15import sys
16
17import numpy as np
18
19import peclet.flow
20import peclet.pnm as pnm
21
22# ---- geometry: two chambers + periodic tube (pnm/flow convention: sdf > 0 in the PORE space) ---
23NX, NY, NZ = 48, 32, 32
24RC, RT = 9.0, 4.0
25CY, CZ = NY / 2.0, NZ / 2.0
26CENTERS_X = (12.0, 36.0)
27
28x, y, z = np.meshgrid(np.arange(NX), np.arange(NY), np.arange(NZ), indexing="ij")
29x = x.astype(np.float64); y = y.astype(np.float64); z = z.astype(np.float64)
30sdf = np.full((NX, NY, NZ), -1e30)
31for cx in CENTERS_X:
32 dx = np.abs(x - cx)
33 dx = np.minimum(dx, NX - dx) # periodic in x
34 d = np.sqrt(dx**2 + (y - CY) ** 2 + (z - CZ) ** 2)
35 sdf = np.maximum(sdf, RC - d)
36sdf = np.maximum(sdf, RT - np.sqrt((y - CY) ** 2 + (z - CZ) ** 2)) # tube along x
37
38# ---- DNS: Stokes flow driven by a body force in x (grad_p_macro = -f) ----------------------
39MU, FX = 0.05, 1.0e-3
40s = peclet.flow.Solver(NX, NY, NZ)
41s.set_rho(1.0)
42s.set_mu(MU)
43s.set_dt(100.0)
44s.set_body_force((FX, 0.0, 0.0)) # one 3-sequence since 1.0.0 (the clean break)
45s.set_advection(False) # Stokes: flow advects by default since 2026-10-23
46s.set_solid(np.asfortranarray(sdf), cutcell_pressure=True) # openness-weighted flux o*u*A
47for _ in range(60):
48 s.step()
49
50u, v, w = s.get_uf(), s.get_vf(), s.get_wf()
51p = s.get_p()
52ox, oy, oz = s.get_ox(), s.get_oy(), s.get_oz()
53
54# DNS flux through every x-plane (openness-weighted -x face fluxes of plane i)
55F_planes = np.array([(ox[i, :, :] * u[i, :, :]).sum() for i in range(NX)])
56F = F_planes.mean()
57plane_dev = np.abs(F_planes - F).max() / abs(F)
58print(f"DNS flux F = {F:.6e} (max plane deviation {plane_dev:.2e})")
59
60# ---- network extraction ------------------------------------------------------------------------
61net = pnm.extract_network_flow(
62 np.ascontiguousarray(sdf.T, dtype=np.float32), [0.0, 0.0, 0.0], [1.0, 1.0, 1.0],
63 np.ascontiguousarray(u.T), np.ascontiguousarray(v.T), np.ascontiguousarray(w.T),
64 np.ascontiguousarray(p.T), np.ascontiguousarray(ox.T), np.ascontiguousarray(oy.T),
65 np.ascontiguousarray(oz.T), grad_p_zyx=[0.0, 0.0, -FX])
66
67pores = net["pores"]
68Q = np.array(net["throat_flow"])
69dp = np.array(net["throat_dp"])
70res = np.array(net["pore_residual"])
71print(f"pores: {len(pores)} throats: {len(net['throats'])}")
72for k, po in enumerate(pores):
73 print(f" pore {k+1}: x=({po.x:6.2f},{po.y:6.2f},{po.z:6.2f}) r={po.radius:5.2f} "
74 f"p={net['pore_pressure'][k]: .4e} residual={res[k]: .3e}")
75for t, (a, b) in enumerate(net["throats"]):
76 print(f" throat {a}-{b}: Q={Q[t]: .6e} dp={dp[t]: .4e} A={net['throat_area'][t]:7.2f} "
77 f"g=Q/dp={Q[t]/dp[t]: .4e}")
78
79# ---- checks ------------------------------------------------------------------------------------
80fails = 0
81def check(name, ok, detail):
82 global fails
83 print(f" [{'PASS' if ok else 'FAIL'}] {name}: {detail}")
84 fails += 0 if ok else 1
85
86
87def check_momentum(tag, net, sdf_xyz, symmetric, on_axis=None):
88 """The momentum/volume extension on a tube network (Stokes, all tubes along x).
89
90 * Cauchy-Schwarz with the SAME discrete weights w = o*A as Q and A_t: on a PLANAR throat (all
91 faces share one normal, |n| = 1) M.n = sum w*un^2 >= Q^2/A_t. (A chamber-tube watershed
92 interface is a staircased cone, |n| ~ 0.5: there M.n is not sum w*un^2 and the bound is not
93 a theorem, so it is only reported.)
94 * Jensen with u.n > 0 (Stokes tube flow, throats oriented along Q): KE flux
95 sum w*|u|^2/2*un >= sum w*un^3/2 >= Q^3/(2 A_t^2), on every throat.
96 * the mean normal points along the tube axis (n/|n| = +-e_x) on the throats of on-axis tubes
97 (`on_axis`, default all; an off-axis capsule meets its chamber on a tilted interface), and
98 on the mirror-symmetric chain (`symmetric`) the momentum flux has no component across it
99 (|M_t| <= 1e-8 |M.n^|);
100 * the pore volumes partition the fluid (sdf > 0 cells) exactly;
101 * the volume-mean total pressure falls along the flow: throat_dp_mean has the sign of Q."""
102 Q = np.asarray(net["throat_flow"])
103 At = np.asarray(net["throat_area"])
104 M = np.asarray(net["throat_momentum_flux_zyx"])[:, ::-1] # -> x, y, z columns
105 K = np.asarray(net["throat_kinetic_energy_flux"])
106 N = np.asarray(net["throat_normal_zyx"])[:, ::-1]
107 dpm = np.asarray(net["throat_dp_mean"])
108 nrm = np.linalg.norm(N, axis=1)
109 Nh = N / nrm[:, None]
110 planar = np.abs(nrm - 1.0) < 1e-12
111 Mn = np.einsum("ij,ij->i", M, Nh)
112 Mt = np.linalg.norm(M - Mn[:, None] * Nh, axis=1)
113 cs = Mn / (Q**2 / At)
114 je = K / (Q**3 / (2 * At**2))
115 for t in range(len(Q)):
116 print(f" {tag} throat {t}: |n|={nrm[t]:.6f} n^_x={Nh[t,0]: .12f} M.n^/(Q^2/A)={cs[t]:.6f} "
117 f"K/(Q^3/2A^2)={je[t]:.6f} |M_t|/|M.n^|={Mt[t]/abs(Mn[t]):.2e} dp_mean={dpm[t]: .4e}")
118 eps = 1e-12
119 check(f"{tag} momentum flux >= Q^2/A_t on planar throats (Cauchy-Schwarz)",
120 bool(planar.any() and np.all(cs[planar] >= 1 - eps)),
121 f"{int(planar.sum())}/{len(Q)} planar, min ratio {np.min(cs[planar]):.6f}")
122 check(f"{tag} KE flux >= Q^3/(2 A_t^2) (Jensen, u.n > 0)", bool(np.all(je >= 1 - eps)),
123 f"min ratio {np.min(je):.6f}")
124 ax = np.arange(len(Q)) if on_axis is None else np.asarray(on_axis, int)
125 dev = np.abs(np.abs(Nh[ax, 0]) - 1)
126 check(f"{tag} throat normal along the tube axis", bool(np.all(dev < 1e-12)),
127 f"{len(ax)} on-axis throats, max ||n^_x|-1| = {np.max(dev):.2e}")
128 if symmetric:
129 check(f"{tag} tangential momentum flux ~ 0 (mirror-symmetric tube)",
130 bool(np.all(Mt <= 1e-8 * np.abs(Mn))), f"max |M_t|/|M.n^| = {np.max(Mt / np.abs(Mn)):.2e}")
131 nfluid = int((sdf_xyz.astype(np.float32) > 0).sum())
132 vol = np.asarray(net["pore_volume"])
133 check(f"{tag} pore volumes partition the fluid", abs(vol.sum() - nfluid) <= 1e-12 * nfluid,
134 f"sum = {vol.sum():.1f} vs {nfluid} fluid cells")
135 check(f"{tag} volume-mean pressure falls along the flow", bool(np.all(Q * dpm > 0)),
136 f"signs Q*dp_mean: {np.sign(Q * dpm).astype(int).tolist()}")
137 # per-pore mechanical-energy balance (rho = 1, body force FX along x, periodic p):
138 # D_p = -sum_t s_t (W_t + rho*KE_t) + f <u_x>_p V_p, s_t = +1 when p is throats[t,0]
139 W = np.asarray(net["throat_pressure_work_flux"])
140 th = np.asarray(net["throats"])
141 npo = len(net["pores"])
142 out = np.zeros(npo)
143 np.add.at(out, th[:, 0] - 1, W + K)
144 np.add.at(out, th[:, 1] - 1, -(W + K))
145 Vp = np.asarray(net["pore_volume"])
146 ux = np.asarray(net["pore_mean_velocity_zyx"])[:, 2]
147 power = FX * ux * Vp
148 D = power - out
149 print(f" {tag} pore energy: body-force power {np.round(power, 6).tolist()}, "
150 f"net (pW + KE) outflow {np.round(out, 6).tolist()}, D_p {np.round(D, 6).tolist()}")
151 check(f"{tag} per-pore dissipation D_p > 0", bool(np.all(D > 0)),
152 f"min D_p / body-force power = {np.min(D / power):.4f}")
153 # globally the throat terms cancel pairwise: sum D_p == f * int u_x dV over the fluid cells
154 check(f"{tag} throat energy fluxes cancel globally", abs(out.sum()) <= 1e-12 * power.sum(),
155 f"|sum net outflow| / sum power = {abs(out.sum()) / power.sum():.2e}")
156
157check("steady plane flux", plane_dev < 1e-6, f"max deviation {plane_dev:.2e}")
158# Watershed topology: the chambers + the wrap tube segment (the mid-tube plateau drains into the
159# chamber basins — only the wrap segment keeps a gid-seam peak). A single loop: #throats == #pores.
160check("pore count", len(pores) == 3, f"{len(pores)} (expect 3: 2 chambers + wrap tube segment)")
161check("single loop", len(net["throats"]) == len(pores),
162 f"{len(net['throats'])} throats vs {len(pores)} pores")
163check("mass residuals", np.abs(res).max() < 1e-4 * abs(F),
164 f"max |residual|/F = {np.abs(res).max()/abs(F):.2e}")
165check("throat flux = DNS flux", np.abs(np.abs(Q) - abs(F)).max() < 1e-3 * abs(F),
166 f"max ||Q|-F|/F = {np.abs(np.abs(Q)-abs(F)).max()/abs(F):.2e}")
167check("Q, dp sign-consistent (g>0)", bool(np.all(Q * dp > 0)),
168 f"signs: {np.sign(Q*dp).astype(int).tolist()}")
169check_momentum("case1", net, sdf, symmetric=True)
170
171# ================= case 2: asymmetric chamber lattice (a genuine network) ======================
172# 4 chambers in a 2x2 (y,z) arrangement, connected along x by tubes of DIFFERENT radii through
173# the periodic boundary — a multi-loop resistor network with real constrictions. On such
174# geometry the throat data must behave like a network: g = Q/dp > 0 on every throat.
175print("\n=== case 2: asymmetric tube lattice ===")
176del s
177NX2, NY2, NZ2 = 48, 48, 48
178sdf2 = np.full((NX2, NY2, NZ2), -1e30)
179x, y, z = np.meshgrid(*(np.arange(d, dtype=np.float64) for d in (NX2, NY2, NZ2)), indexing="ij")
180tubes = [] # (cy, cz, radius) — one x-tube per chamber column, different radii
181for (cy, cz, rt) in ((12.0, 12.0, 3.0), (12.0, 36.0, 4.0), (36.0, 12.0, 5.0), (36.0, 36.0, 6.0)):
182 for cx in (12.0, 36.0):
183 dx = np.abs(x - cx); dx = np.minimum(dx, NX2 - dx)
184 sdf2 = np.maximum(sdf2, 9.0 - np.sqrt(dx**2 + (y - cy) ** 2 + (z - cz) ** 2))
185 sdf2 = np.maximum(sdf2, rt - np.sqrt((y - cy) ** 2 + (z - cz) ** 2))
186s = peclet.flow.Solver(NX2, NY2, NZ2)
187s.set_rho(1.0); s.set_mu(MU); s.set_dt(100.0)
188s.set_body_force((FX, 0.0, 0.0)) # one 3-sequence since 1.0.0 (the clean break)
189s.set_advection(False) # Stokes: flow advects by default since 2026-10-23
190s.set_solid(np.asfortranarray(sdf2), cutcell_pressure=True)
191for _ in range(60):
192 s.step()
193u, v, w, p = s.get_uf(), s.get_vf(), s.get_wf(), s.get_p()
194ox, oy, oz = s.get_ox(), s.get_oy(), s.get_oz()
195net2 = pnm.extract_network_flow(
196 np.ascontiguousarray(sdf2.T, dtype=np.float32), [0.0, 0.0, 0.0], [1.0, 1.0, 1.0],
197 np.ascontiguousarray(u.T), np.ascontiguousarray(v.T), np.ascontiguousarray(w.T),
198 np.ascontiguousarray(p.T), np.ascontiguousarray(ox.T), np.ascontiguousarray(oy.T),
199 np.ascontiguousarray(oz.T), grad_p_zyx=[0.0, 0.0, -FX])
200Q2 = np.array(net2["throat_flow"])
201dp2 = np.array(net2["throat_dp"])
202res2 = np.array(net2["pore_residual"])
203F2 = np.array([(ox[i, :, :] * u[i, :, :]).sum() for i in range(NX2)]).mean()
204print(f"pores {len(net2['pores'])}, throats {len(Q2)}, F = {F2:.4e}")
205for t, (a, b) in enumerate(net2["throats"]):
206 print(f" throat {a}-{b}: Q={Q2[t]: .4e} dp={dp2[t]: .4e} g={Q2[t]/dp2[t]: .4e}")
207check("case2 mass residuals", np.abs(res2).max() < 1e-4 * abs(F2),
208 f"max |residual|/F = {np.abs(res2).max()/abs(F2):.2e}")
209check("case2 g>0 on all throats", bool(np.all(Q2 * dp2 > 0)),
210 f"{int((Q2*dp2 > 0).sum())}/{len(Q2)}")
211# the four tube columns are independent parallel channels of 3 throats each, every throat in a
212# column carrying that column's full flux: sum |Q| = 3 * F_total
213check("case2 total flux", abs(np.abs(Q2).sum() / 3.0 - abs(F2)) < 1e-2 * abs(F2),
214 f"sum|Q|/3 = {np.abs(Q2).sum()/3.0:.4e} vs F = {F2:.4e}")
215
216# ================= case 3: ghost-cell IBM variant (set_ghost_projection) =======================
217# Same chamber-tube chain, solved with the directional ghost-cell projection. The projection
218# there conserves fluxes through the BINARY (COUPLED) openness — flow's get_*_proj getters
219# return the operative openness in either mode, so the same extraction call works for both IBMs.
220print("\n=== case 3: chamber-tube chain, ghost-cell IBM ===")
221del s
222s = peclet.flow.Solver(NX, NY, NZ)
223s.set_rho(1.0); s.set_mu(MU); s.set_dt(100.0)
224s.set_body_force((FX, 0.0, 0.0)) # one 3-sequence since 1.0.0 (the clean break)
225s.set_advection(False) # Stokes: flow advects by default since 2026-10-23
226s.diagnostics.set_ghost_projection(True) # diagnostics tier since 1.0.0
227s.set_solid(np.asfortranarray(sdf), cutcell_pressure=True)
228for _ in range(60):
229 s.step()
230u, v, w, p = s.get_uf(), s.get_vf(), s.get_wf(), s.get_p()
231ox, oy, oz = s.get_ox_proj(), s.get_oy_proj(), s.get_oz_proj()
232F3_planes = np.array([(ox[i, :, :] * u[i, :, :]).sum() for i in range(NX)])
233F3 = F3_planes.mean()
234plane_dev3 = np.abs(F3_planes - F3).max() / abs(F3)
235net3 = pnm.extract_network_flow(
236 np.ascontiguousarray(sdf.T, dtype=np.float32), [0.0, 0.0, 0.0], [1.0, 1.0, 1.0],
237 np.ascontiguousarray(u.T), np.ascontiguousarray(v.T), np.ascontiguousarray(w.T),
238 np.ascontiguousarray(p.T), np.ascontiguousarray(ox.T), np.ascontiguousarray(oy.T),
239 np.ascontiguousarray(oz.T), grad_p_zyx=[0.0, 0.0, -FX])
240Q3 = np.array(net3["throat_flow"])
241dp3 = np.array(net3["throat_dp"])
242res3 = np.array(net3["pore_residual"])
243print(f"ghost DNS flux F = {F3:.6e} (vs cut-cell {F:.6e}); "
244 f"{len(net3['pores'])} pores, {len(Q3)} throats")
245for t, (a, b) in enumerate(net3["throats"]):
246 print(f" throat {a}-{b}: Q={Q3[t]: .6e} dp={dp3[t]: .4e}")
247# Ghost-cell IBM is pointwise 2nd-order but NOT locally mass-conserving at the wall (the
248# closure rows absorb truncation error as wall transpiration), so the network bookkeeping is
249# truncation-accurate here, not machine-exact: pore_residual becomes the per-pore wall leak.
250# Measured on this geometry: residual/F 3.2e-2 (h) -> 4.9e-3 (h/2), order ~2.7; ||Q|-F|/F
251# order ~1.8. Tolerances below are set for THIS resolution (tube radius = 4 cells).
252check("case3 steady plane flux (truncation)", plane_dev3 < 5e-2,
253 f"max deviation {plane_dev3:.2e} (wall transpiration, converges ~O(h^2))")
254check("case3 mass residuals (truncation)", np.abs(res3).max() < 5e-2 * abs(F3),
255 f"max |residual|/F = {np.abs(res3).max()/abs(F3):.2e}")
256check("case3 throat flux = DNS flux (truncation)",
257 np.abs(np.abs(Q3) - abs(F3)).max() < 6e-2 * abs(F3),
258 f"max ||Q|-F|/F = {np.abs(np.abs(Q3)-abs(F3)).max()/abs(F3):.2e}")
259check("case3 g>0 on all throats", bool(np.all(Q3 * dp3 > 0)),
260 f"signs: {np.sign(Q3*dp3).astype(int).tolist()}")
261check("case3 flux agrees with cut-cell IBM", abs(F3 - F) < 0.10 * abs(F),
262 f"rel diff {(F3-F)/F:.2%} (coarse tube: r = 4 cells)")
263
264# ================= case 4: PARALLEL throats (per-patch resolution) =============================
265# Two chambers connected by TWO capsule tubes of different radii (same pore pair, two disjoint
266# interfaces -> two parallel throats) + a wrap tube as the return path. Pair-keyed throats would
267# merge the capsules into one entry; per-patch must report pair (1,2) twice, with Q_A + Q_B = F
268# and the fatter capsule carrying more.
269print("\n=== case 4: parallel capsule throats ===")
270del s
271NX4, NY4, NZ4 = 48, 32, 32
272x, y, z = np.meshgrid(*(np.arange(d, dtype=np.float64) for d in (NX4, NY4, NZ4)), indexing="ij")
273sdf4 = np.full((NX4, NY4, NZ4), -1e30)
274for cx in (12.0, 36.0): # chambers
275 dx = np.abs(x - cx); dx = np.minimum(dx, NX4 - dx)
276 sdf4 = np.maximum(sdf4, 8.0 - np.sqrt(dx**2 + (y - 16.0) ** 2 + (z - 16.0) ** 2))
277# capsule ridges must DRAIN into the chamber basins (no own pore): needs chamber sdf >= r one
278# cell off the ridge at the junction, i.e. 8 - |16-cy| + 1 >= r — hence cy near the axis.
279for (cy, rt) in ((12.0, 3.0), (20.0, 4.2)): # capsules between the chambers (no wrap)
280 xs = np.clip(x, 12.0, 36.0)
281 sdf4 = np.maximum(sdf4, rt - np.sqrt((x - xs) ** 2 + (y - cy) ** 2 + (z - 16.0) ** 2))
282xw = np.where(x < 12.0, x + NX4, x) # wrap capsule: the return path, own pore at the gid seam
283xs = np.clip(xw, 36.0, 12.0 + NX4)
284sdf4 = np.maximum(sdf4, 4.0 - np.sqrt((xw - xs) ** 2 + (y - 16.0) ** 2 + (z - 16.0) ** 2))
285
286s = peclet.flow.Solver(NX4, NY4, NZ4)
287s.set_rho(1.0); s.set_mu(MU); s.set_dt(100.0)
288s.set_body_force((FX, 0.0, 0.0)) # one 3-sequence since 1.0.0 (the clean break)
289s.set_advection(False) # Stokes: flow advects by default since 2026-10-23
290s.set_solid(np.asfortranarray(sdf4), cutcell_pressure=True)
291for _ in range(60):
292 s.step()
293u, v, w, p = s.get_uf(), s.get_vf(), s.get_wf(), s.get_p()
294ox, oy, oz = s.get_ox(), s.get_oy(), s.get_oz()
295F4 = np.array([(ox[i, :, :] * u[i, :, :]).sum() for i in range(NX4)]).mean()
296net4 = pnm.extract_network_flow(
297 np.ascontiguousarray(sdf4.T, dtype=np.float32), [0.0, 0.0, 0.0], [1.0, 1.0, 1.0],
298 np.ascontiguousarray(u.T), np.ascontiguousarray(v.T), np.ascontiguousarray(w.T),
299 np.ascontiguousarray(p.T), np.ascontiguousarray(ox.T), np.ascontiguousarray(oy.T),
300 np.ascontiguousarray(oz.T), grad_p_zyx=[0.0, 0.0, -FX])
301Q4 = np.array(net4["throat_flow"])
302dp4 = np.array(net4["throat_dp"])
303res4 = np.array(net4["pore_residual"])
304th4 = net4["throats"].tolist() # (M,2) int32 array -> [[a, b], ...] for the == tests below
305print(f"pores {len(net4['pores'])}, throats {len(Q4)}, F = {F4:.4e}")
306for t, (a, b) in enumerate(th4):
307 print(f" throat {a}-{b}: Q={Q4[t]: .6e} dp={dp4[t]: .4e} A={net4['throat_area'][t]:7.2f}")
308par = [t for t, ab in enumerate(th4) if ab == [1, 2]]
309check("case4 pore count", len(net4["pores"]) == 3, f"{len(net4['pores'])} (2 chambers + wrap pore)")
310check("case4 parallel pair (1,2) twice", len(par) == 2,
311 f"pair (1,2) appears {len(par)}x of {len(Q4)} throats")
312check("case4 mass residuals", np.abs(res4).max() < 1e-4 * abs(F4),
313 f"max |residual|/F = {np.abs(res4).max()/abs(F4):.2e}")
314if len(par) == 2:
315 qA, qB = Q4[par[0]], Q4[par[1]]
316 check("case4 parallel split sums to F", abs(qA + qB - F4) < 1e-3 * abs(F4),
317 f"Q_A + Q_B = {qA+qB:.6e} vs F = {F4:.6e}")
318 check("case4 both capsules carry forward flow", qA > 0 and qB > 0,
319 f"Q_A = {qA:.3e}, Q_B = {qB:.3e}")
320 check("case4 fatter capsule carries more", max(qA, qB) > 1.5 * min(qA, qB),
321 f"ratio {max(qA,qB)/min(qA,qB):.2f} (radii 4.5 vs 3)")
322wrapT = [t for t, ab in enumerate(th4) if ab != [1, 2]]
323check("case4 wrap throats carry F", bool(np.all(np.abs(np.abs(Q4[wrapT]) - abs(F4)) < 1e-3 * abs(F4))),
324 f"|Q| = {np.abs(Q4[wrapT]).tolist()}")
325check("case4 g>0 on all throats", bool(np.all(Q4 * dp4 > 0)),
326 f"signs: {np.sign(Q4*dp4).astype(int).tolist()}")
327check_momentum("case4", net4, sdf4, symmetric=False, on_axis=wrapT)
328
329print("PASS" if fails == 0 else f"FAIL ({fails})")
330del s # release the solver's device Views BEFORE interpreter exit (flow's finalize contract)
331sys.exit(1 if fails else 0)
check(name, ok, detail)
check_momentum(tag, net, sdf_xyz, symmetric, on_axis=None)