flow 1.4.0
Kokkos cut-cell IBM incompressible Navier-Stokes solver + pnm pore extraction
Loading...
Searching...
No Matches
sdflow_regression Namespace Reference

Functions

 zh_ref (phi)
 _grid (N)
 _minimg (d, N)
 sdf_zh_sphere (N, phi=0.216)
 sdf_random_spheres (N, n=8, r_frac=0.18, jit=0.06, seed=12345)
 _hollow_cyl_sdf (X, Y, Z, c, axis, r_out, r_in, H, N)
 sdf_hollow_rings (N)
 run_case (name, N, cfg, quiet=True, solver="staggered", scheme="gauge-exact")
 fit_order (Ns, vals)
 run_all (cfg, cases, solver="staggered", scheme="gauge-exact")
 compare (base, cur, solver="staggered")
 main ()

Variables

 HERE = os.path.dirname(os.path.abspath(__file__))
 ROOT = os.path.abspath(os.path.join(HERE, "..", ".."))
 BASELINE = os.path.join(HERE, "perf_baseline.json")
list ZH_PHI = [0.000125, 0.001, 0.008, 0.027, 0.064, 0.125, 0.216, 0.343, 0.45, 0.5236]
list ZH_K = [1.096, 1.212, 1.525, 2.008, 2.810, 4.292, 7.442, 15.4, 28.1, 42.1]
dict CASES
 CFG
 TOL

Detailed Description

Single-GPU accuracy + efficiency regression suite for the `sdflow` cut-cell IBM Stokes solver.

Three creeping-flow (Stokes) cases, each as a GRID-CONVERGENCE study:
  * zh_sphere      -- simple-cubic single sphere; drag factor K vs Zick & Homsy (1982) (external ref);
  * random_spheres -- a small packed bed of (reproducibly) jittered spheres; Darcy permeability k;
  * hollow_rings   -- a small packed bed of Raschig rings (hollow cylinders); Darcy permeability k.

For each grid N we record the ACCURACY metric (K or k) and the EFFICIENCY counters the solver exposes:
total pressure-solver (MG-PCG) iterations, per-step pressure iterations, Picard outer iterations, the
number of steps to steady state, the cut-cell flux divergence, and the wall-clock time. Across the grid
sweep we fit the observed order of convergence p (f(N) = f_inf + C N^-p) and the Richardson-extrapolated
value f_inf.

All numbers are saved to perf_baseline.json. Re-running compares against that baseline within tolerances,
so a code change that degrades accuracy OR efficiency is caught.

Usage:
  python tests/regression/sdflow_regression.py              # run + check against the baseline (exit 0/1)
  python tests/regression/sdflow_regression.py --update     # run + (re)write the baseline
  python tests/regression/sdflow_regression.py --cases zh_sphere,random_spheres
  python tests/regression/sdflow_regression.py --build build_mpi    # pick the flow build dir
                                                                     # (only consulted if peclet.flow
                                                                     # isn't already importable, same
                                                                     # as PECLET_FLOW_BUILD)
  python tests/regression/sdflow_regression.py --quick      # coarser grids, looser march (fast smoke)

Function Documentation

◆ zh_ref()

sdflow_regression.zh_ref ( phi)

Definition at line 48 of file sdflow_regression.py.

Referenced by run_all(), and sdf_zh_sphere().

◆ _grid()

sdflow_regression._grid ( N)
protected

Definition at line 53 of file sdflow_regression.py.

Referenced by sdf_hollow_rings(), sdf_random_spheres(), and sdf_zh_sphere().

◆ _minimg()

sdflow_regression._minimg ( d,
N )
protected

Definition at line 58 of file sdflow_regression.py.

Referenced by _hollow_cyl_sdf(), and sdf_random_spheres().

◆ sdf_zh_sphere()

sdflow_regression.sdf_zh_sphere ( N,
phi = 0.216 )
Single SC sphere centred in the periodic cube; returns (sdf, info).

Definition at line 62 of file sdflow_regression.py.

References _grid(), and zh_ref().

◆ sdf_random_spheres()

sdflow_regression.sdf_random_spheres ( N,
n = 8,
r_frac = 0.18,
jit = 0.06,
seed = 12345 )
Small packed bed: `n` spheres of radius r_frac*N on a jittered 2x2x2 lattice (fixed seed). The shape
is self-similar in N (same relative geometry, finer grid) -> a true grid-convergence study of k*.

Definition at line 71 of file sdflow_regression.py.

References _grid(), and _minimg().

◆ _hollow_cyl_sdf()

sdflow_regression._hollow_cyl_sdf ( X,
Y,
Z,
c,
axis,
r_out,
r_in,
H,
N )
protected
SDF of one Raschig ring (hollow cylinder): annulus [r_in,r_out] x slab |axial|<=H/2, CSG-intersection.

Definition at line 87 of file sdflow_regression.py.

References _minimg().

Referenced by sdf_hollow_rings().

◆ sdf_hollow_rings()

sdflow_regression.sdf_hollow_rings ( N)
Small packed bed of 3 Raschig rings at fixed positions/orientations (reproducible).

Definition at line 99 of file sdflow_regression.py.

References _grid(), and _hollow_cyl_sdf().

◆ run_case()

sdflow_regression.run_case ( name,
N,
cfg,
quiet = True,
solver = "staggered",
scheme = "gauge-exact" )

Definition at line 124 of file sdflow_regression.py.

References mean().

Referenced by run_all().

◆ fit_order()

sdflow_regression.fit_order ( Ns,
vals )
Fit f(N) = f_inf + C N^-p (grid-search p, linear LS for f_inf,C). Returns (order p, f_inf).

Definition at line 176 of file sdflow_regression.py.

Referenced by run_all().

◆ run_all()

sdflow_regression.run_all ( cfg,
cases,
solver = "staggered",
scheme = "gauge-exact" )

Definition at line 189 of file sdflow_regression.py.

References fit_order(), run_case(), and zh_ref().

Referenced by main().

◆ compare()

sdflow_regression.compare ( base,
cur,
solver = "staggered" )

Definition at line 220 of file sdflow_regression.py.

Referenced by main().

◆ main()

sdflow_regression.main ( )

Definition at line 263 of file sdflow_regression.py.

References compare(), main(), and run_all().

Referenced by main().

Variable Documentation

◆ HERE

sdflow_regression.HERE = os.path.dirname(os.path.abspath(__file__))

Definition at line 36 of file sdflow_regression.py.

◆ ROOT

sdflow_regression.ROOT = os.path.abspath(os.path.join(HERE, "..", ".."))

Definition at line 37 of file sdflow_regression.py.

◆ BASELINE

sdflow_regression.BASELINE = os.path.join(HERE, "perf_baseline.json")

Definition at line 38 of file sdflow_regression.py.

◆ ZH_PHI

list sdflow_regression.ZH_PHI = [0.000125, 0.001, 0.008, 0.027, 0.064, 0.125, 0.216, 0.343, 0.45, 0.5236]

Definition at line 44 of file sdflow_regression.py.

◆ ZH_K

list sdflow_regression.ZH_K = [1.096, 1.212, 1.525, 2.008, 2.810, 4.292, 7.442, 15.4, 28.1, 42.1]

Definition at line 45 of file sdflow_regression.py.

◆ CASES

dict sdflow_regression.CASES
Initial value:
1= {
2 "zh_sphere": {"sdf": sdf_zh_sphere, "grids": [16, 24, 32, 48, 64], "metric": "K"},
3 "random_spheres": {"sdf": sdf_random_spheres, "grids": [24, 32, 48, 64], "metric": "k*"},
4 "hollow_rings": {"sdf": sdf_hollow_rings, "grids": [24, 32, 48, 64], "metric": "k*"},
5}

Definition at line 112 of file sdflow_regression.py.

◆ CFG

sdflow_regression.CFG
Initial value:
1= dict(rho=1.0, mu=0.1, dt=60.0, F=1e-3, vel_sweeps=80, pcg_maxit=300, pcg_rtol=1e-8,
2 coarse="rediscretized", conv_tol=1e-5, check_every=5, max_steps=400, min_steps=15)

Definition at line 119 of file sdflow_regression.py.

◆ TOL

sdflow_regression.TOL
Initial value:
1= dict(metric_rel=0.015, order_abs=0.4, extrap_rel=0.02,
2 piter_total_rel=0.25, piter_step_abs=2.0, steps_rel=0.35, div_floor=1e-7)

Definition at line 216 of file sdflow_regression.py.