pnm 1.0.3
peclet.pnm — pore-network extraction from SDF geometry (Kokkos)
Loading...
Searching...
No Matches
verify_network_flow Namespace Reference

Functions

 check (name, ok, detail)
 check_momentum (tag, net, sdf_xyz, symmetric, on_axis=None)

Variables

 NX
 NY
 NZ
 RC
 RT
 CY
 CZ
tuple CENTERS_X = (12.0, 36.0)
 x = z.astype(np.float64)
 y
 z
 indexing
 sdf = np.full((NX, NY, NZ), -1e30)
 dx = np.abs(x - cx)
 d = np.sqrt(dx**2 + (y - CY) ** 2 + (z - CZ) ** 2)
 MU
 FX
 s = peclet.flow.Solver(NX, NY, NZ)
 cutcell_pressure
 u
 v
 w
 p = s.get_p()
 ox
 oy
 oz
 F_planes = np.array([(ox[i, :, :] * u[i, :, :]).sum() for i in range(NX)])
 F = F_planes.mean()
 plane_dev = np.abs(F_planes - F).max() / abs(F)
 net
 pores = net["pores"]
 Q = np.array(net["throat_flow"])
 dp = np.array(net["throat_dp"])
 res = np.array(net["pore_residual"])
int fails = 0
 symmetric
 NX2
 NY2
 NZ2
 sdf2 = np.full((NX2, NY2, NZ2), -1e30)
list tubes = []
 net2
 Q2 = np.array(net2["throat_flow"])
 dp2 = np.array(net2["throat_dp"])
 res2 = np.array(net2["pore_residual"])
 F2 = np.array([(ox[i, :, :] * u[i, :, :]).sum() for i in range(NX2)]).mean()
 F3_planes = np.array([(ox[i, :, :] * u[i, :, :]).sum() for i in range(NX)])
 F3 = F3_planes.mean()
 plane_dev3 = np.abs(F3_planes - F3).max() / abs(F3)
 net3
 Q3 = np.array(net3["throat_flow"])
 dp3 = np.array(net3["throat_dp"])
 res3 = np.array(net3["pore_residual"])
 NX4
 NY4
 NZ4
 sdf4 = np.full((NX4, NY4, NZ4), -1e30)
 xs = np.clip(x, 12.0, 36.0)
 xw = np.where(x < 12.0, x + NX4, x)
 F4 = np.array([(ox[i, :, :] * u[i, :, :]).sum() for i in range(NX4)]).mean()
 net4
 Q4 = np.array(net4["throat_flow"])
 dp4 = np.array(net4["throat_dp"])
 res4 = np.array(net4["pore_residual"])
 th4 = net4["throats"].tolist()
list par = [t for t, ab in enumerate(th4) if ab == [1, 2]]
 qA
 qB
list wrapT = [t for t, ab in enumerate(th4) if ab != [1, 2]]
 False
 on_axis

Detailed Description

Quantitative validation of pnm.extract_network_flow against a peclet.flow DNS.

Geometry: a periodic chamber-tube chain — two spherical chambers connected by a straight
cylindrical tube along x (also through the periodic boundary). The watershed segments this into
4 pores (2 chambers + 2 tube segments) in a single loop, so by mass conservation EVERY pore-pore
throat must carry the full DNS flux F (measured independently as the openness-weighted x-flux
through a grid plane). Checks:
  1. per-pore residual (signed flux over the whole pore boundary) ~ solver tolerance,
  2. |Q_throat| == F for every throat (small leakage through near-wall faces allowed),
  3. Q and the total-pressure drop dp agree in sign on every throat (g = Q/dp > 0),
  4. the DNS plane flux is x-independent (steady, converged).

Run:  PYTHONPATH=<pnm/build>:<flow/build> python scripts/verify_network_flow.py

Function Documentation

◆ check()

verify_network_flow.check ( name,
ok,
detail )

Definition at line 81 of file verify_network_flow.py.

Referenced by check_momentum().

◆ check_momentum()

verify_network_flow.check_momentum ( tag,
net,
sdf_xyz,
symmetric,
on_axis = None )
The momentum/volume extension on a tube network (Stokes, all tubes along x).

* Cauchy-Schwarz with the SAME discrete weights w = o*A as Q and A_t: on a PLANAR throat (all
  faces share one normal, |n| = 1) M.n = sum w*un^2 >= Q^2/A_t. (A chamber-tube watershed
  interface is a staircased cone, |n| ~ 0.5: there M.n is not sum w*un^2 and the bound is not
  a theorem, so it is only reported.)
* Jensen with u.n > 0 (Stokes tube flow, throats oriented along Q): KE flux
  sum w*|u|^2/2*un >= sum w*un^3/2 >= Q^3/(2 A_t^2), on every throat.
* the mean normal points along the tube axis (n/|n| = +-e_x) on the throats of on-axis tubes
  (`on_axis`, default all; an off-axis capsule meets its chamber on a tilted interface), and
  on the mirror-symmetric chain (`symmetric`) the momentum flux has no component across it
  (|M_t| <= 1e-8 |M.n^|);
* the pore volumes partition the fluid (sdf > 0 cells) exactly;
* the volume-mean total pressure falls along the flow: throat_dp_mean has the sign of Q.

Definition at line 87 of file verify_network_flow.py.

References check().

Variable Documentation

◆ NX

verify_network_flow.NX

Definition at line 23 of file verify_network_flow.py.

◆ NY

verify_network_flow.NY

Definition at line 23 of file verify_network_flow.py.

◆ NZ

verify_network_flow.NZ

Definition at line 23 of file verify_network_flow.py.

◆ RC

verify_network_flow.RC

Definition at line 24 of file verify_network_flow.py.

◆ RT

verify_network_flow.RT

Definition at line 24 of file verify_network_flow.py.

◆ CY

verify_network_flow.CY

Definition at line 25 of file verify_network_flow.py.

◆ CZ

verify_network_flow.CZ

Definition at line 25 of file verify_network_flow.py.

◆ CENTERS_X

tuple verify_network_flow.CENTERS_X = (12.0, 36.0)

Definition at line 26 of file verify_network_flow.py.

◆ x

verify_network_flow.x = z.astype(np.float64)

Definition at line 28 of file verify_network_flow.py.

◆ y

verify_network_flow.y

Definition at line 28 of file verify_network_flow.py.

◆ z

verify_network_flow.z

Definition at line 28 of file verify_network_flow.py.

◆ indexing

verify_network_flow.indexing

Definition at line 28 of file verify_network_flow.py.

◆ sdf

verify_network_flow.sdf = np.full((NX, NY, NZ), -1e30)

Definition at line 30 of file verify_network_flow.py.

◆ dx

verify_network_flow.dx = np.abs(x - cx)

Definition at line 32 of file verify_network_flow.py.

◆ d

verify_network_flow.d = np.sqrt(dx**2 + (y - CY) ** 2 + (z - CZ) ** 2)

Definition at line 34 of file verify_network_flow.py.

◆ MU

verify_network_flow.MU

Definition at line 39 of file verify_network_flow.py.

◆ FX

verify_network_flow.FX

Definition at line 39 of file verify_network_flow.py.

◆ s

verify_network_flow.s = peclet.flow.Solver(NX, NY, NZ)

Definition at line 40 of file verify_network_flow.py.

◆ cutcell_pressure

verify_network_flow.cutcell_pressure

Definition at line 46 of file verify_network_flow.py.

◆ u

verify_network_flow.u

Definition at line 50 of file verify_network_flow.py.

◆ v

verify_network_flow.v

Definition at line 50 of file verify_network_flow.py.

◆ w

verify_network_flow.w

Definition at line 50 of file verify_network_flow.py.

◆ p

verify_network_flow.p = s.get_p()

Definition at line 51 of file verify_network_flow.py.

◆ ox

verify_network_flow.ox

Definition at line 52 of file verify_network_flow.py.

◆ oy

verify_network_flow.oy

Definition at line 52 of file verify_network_flow.py.

◆ oz

verify_network_flow.oz

Definition at line 52 of file verify_network_flow.py.

◆ F_planes

verify_network_flow.F_planes = np.array([(ox[i, :, :] * u[i, :, :]).sum() for i in range(NX)])

Definition at line 55 of file verify_network_flow.py.

◆ F

verify_network_flow.F = F_planes.mean()

Definition at line 56 of file verify_network_flow.py.

◆ plane_dev

verify_network_flow.plane_dev = np.abs(F_planes - F).max() / abs(F)

Definition at line 57 of file verify_network_flow.py.

◆ net

verify_network_flow.net
Initial value:
1= pnm.extract_network_flow(
2 np.ascontiguousarray(sdf.T, dtype=np.float32), [0.0, 0.0, 0.0], [1.0, 1.0, 1.0],
3 np.ascontiguousarray(u.T), np.ascontiguousarray(v.T), np.ascontiguousarray(w.T),
4 np.ascontiguousarray(p.T), np.ascontiguousarray(ox.T), np.ascontiguousarray(oy.T),
5 np.ascontiguousarray(oz.T), grad_p_zyx=[0.0, 0.0, -FX])

Definition at line 61 of file verify_network_flow.py.

◆ pores

verify_network_flow.pores = net["pores"]

Definition at line 67 of file verify_network_flow.py.

◆ Q

verify_network_flow.Q = np.array(net["throat_flow"])

Definition at line 68 of file verify_network_flow.py.

◆ dp

verify_network_flow.dp = np.array(net["throat_dp"])

Definition at line 69 of file verify_network_flow.py.

◆ res

verify_network_flow.res = np.array(net["pore_residual"])

Definition at line 70 of file verify_network_flow.py.

◆ fails

int verify_network_flow.fails = 0

Definition at line 80 of file verify_network_flow.py.

◆ symmetric

verify_network_flow.symmetric

Definition at line 169 of file verify_network_flow.py.

◆ NX2

verify_network_flow.NX2

Definition at line 177 of file verify_network_flow.py.

◆ NY2

verify_network_flow.NY2

Definition at line 177 of file verify_network_flow.py.

◆ NZ2

verify_network_flow.NZ2

Definition at line 177 of file verify_network_flow.py.

◆ sdf2

verify_network_flow.sdf2 = np.full((NX2, NY2, NZ2), -1e30)

Definition at line 178 of file verify_network_flow.py.

◆ tubes

list verify_network_flow.tubes = []

Definition at line 180 of file verify_network_flow.py.

◆ net2

verify_network_flow.net2
Initial value:
1= pnm.extract_network_flow(
2 np.ascontiguousarray(sdf2.T, dtype=np.float32), [0.0, 0.0, 0.0], [1.0, 1.0, 1.0],
3 np.ascontiguousarray(u.T), np.ascontiguousarray(v.T), np.ascontiguousarray(w.T),
4 np.ascontiguousarray(p.T), np.ascontiguousarray(ox.T), np.ascontiguousarray(oy.T),
5 np.ascontiguousarray(oz.T), grad_p_zyx=[0.0, 0.0, -FX])

Definition at line 195 of file verify_network_flow.py.

◆ Q2

verify_network_flow.Q2 = np.array(net2["throat_flow"])

Definition at line 200 of file verify_network_flow.py.

◆ dp2

verify_network_flow.dp2 = np.array(net2["throat_dp"])

Definition at line 201 of file verify_network_flow.py.

◆ res2

verify_network_flow.res2 = np.array(net2["pore_residual"])

Definition at line 202 of file verify_network_flow.py.

◆ F2

verify_network_flow.F2 = np.array([(ox[i, :, :] * u[i, :, :]).sum() for i in range(NX2)]).mean()

Definition at line 203 of file verify_network_flow.py.

◆ F3_planes

verify_network_flow.F3_planes = np.array([(ox[i, :, :] * u[i, :, :]).sum() for i in range(NX)])

Definition at line 232 of file verify_network_flow.py.

◆ F3

verify_network_flow.F3 = F3_planes.mean()

Definition at line 233 of file verify_network_flow.py.

◆ plane_dev3

verify_network_flow.plane_dev3 = np.abs(F3_planes - F3).max() / abs(F3)

Definition at line 234 of file verify_network_flow.py.

◆ net3

verify_network_flow.net3
Initial value:
1= pnm.extract_network_flow(
2 np.ascontiguousarray(sdf.T, dtype=np.float32), [0.0, 0.0, 0.0], [1.0, 1.0, 1.0],
3 np.ascontiguousarray(u.T), np.ascontiguousarray(v.T), np.ascontiguousarray(w.T),
4 np.ascontiguousarray(p.T), np.ascontiguousarray(ox.T), np.ascontiguousarray(oy.T),
5 np.ascontiguousarray(oz.T), grad_p_zyx=[0.0, 0.0, -FX])

Definition at line 235 of file verify_network_flow.py.

◆ Q3

verify_network_flow.Q3 = np.array(net3["throat_flow"])

Definition at line 240 of file verify_network_flow.py.

◆ dp3

verify_network_flow.dp3 = np.array(net3["throat_dp"])

Definition at line 241 of file verify_network_flow.py.

◆ res3

verify_network_flow.res3 = np.array(net3["pore_residual"])

Definition at line 242 of file verify_network_flow.py.

◆ NX4

verify_network_flow.NX4

Definition at line 271 of file verify_network_flow.py.

◆ NY4

verify_network_flow.NY4

Definition at line 271 of file verify_network_flow.py.

◆ NZ4

verify_network_flow.NZ4

Definition at line 271 of file verify_network_flow.py.

◆ sdf4

verify_network_flow.sdf4 = np.full((NX4, NY4, NZ4), -1e30)

Definition at line 273 of file verify_network_flow.py.

◆ xs

verify_network_flow.xs = np.clip(x, 12.0, 36.0)

Definition at line 280 of file verify_network_flow.py.

◆ xw

verify_network_flow.xw = np.where(x < 12.0, x + NX4, x)

Definition at line 282 of file verify_network_flow.py.

◆ F4

verify_network_flow.F4 = np.array([(ox[i, :, :] * u[i, :, :]).sum() for i in range(NX4)]).mean()

Definition at line 295 of file verify_network_flow.py.

◆ net4

verify_network_flow.net4
Initial value:
1= pnm.extract_network_flow(
2 np.ascontiguousarray(sdf4.T, dtype=np.float32), [0.0, 0.0, 0.0], [1.0, 1.0, 1.0],
3 np.ascontiguousarray(u.T), np.ascontiguousarray(v.T), np.ascontiguousarray(w.T),
4 np.ascontiguousarray(p.T), np.ascontiguousarray(ox.T), np.ascontiguousarray(oy.T),
5 np.ascontiguousarray(oz.T), grad_p_zyx=[0.0, 0.0, -FX])

Definition at line 296 of file verify_network_flow.py.

◆ Q4

verify_network_flow.Q4 = np.array(net4["throat_flow"])

Definition at line 301 of file verify_network_flow.py.

◆ dp4

verify_network_flow.dp4 = np.array(net4["throat_dp"])

Definition at line 302 of file verify_network_flow.py.

◆ res4

verify_network_flow.res4 = np.array(net4["pore_residual"])

Definition at line 303 of file verify_network_flow.py.

◆ th4

verify_network_flow.th4 = net4["throats"].tolist()

Definition at line 304 of file verify_network_flow.py.

◆ par

list verify_network_flow.par = [t for t, ab in enumerate(th4) if ab == [1, 2]]

Definition at line 308 of file verify_network_flow.py.

◆ qA

verify_network_flow.qA

Definition at line 315 of file verify_network_flow.py.

◆ qB

verify_network_flow.qB

Definition at line 315 of file verify_network_flow.py.

◆ wrapT

list verify_network_flow.wrapT = [t for t, ab in enumerate(th4) if ab != [1, 2]]

Definition at line 322 of file verify_network_flow.py.

◆ False

verify_network_flow.False

Definition at line 327 of file verify_network_flow.py.

◆ on_axis

verify_network_flow.on_axis

Definition at line 327 of file verify_network_flow.py.