42def run(Re, S=16, Lr=12, U_in=1.0, nz=4, dt=0.4, max_steps=8000):
45 s = sdflow.SolverColocated(L, H, nz)
46 s.set_rho(1.0); s.set_mu(nu); s.set_dt(dt); s.set_advection(
True)
48 s.set_domain_bc(
"+x",
"outflow")
49 s.set_domain_bc(
"-y",
"wall"); s.set_domain_bc(
"+y",
"wall")
50 s.diagnostics.set_velocity_solver_params(60)
51 s.set_pressure_pcg(
True, 400, 1e-9)
52 s.set_pressure_geometry(np.asfortranarray(np.full((L, H, nz), 1e30)))
57 for it
in range(max_steps):
61 if it > 3000
and xr > S
and abs(xr - prev) < 1e-3 * S:
67 flux_in = float(u[2, :, nz // 2].sum())
68 flux_out = float(u[L - 3, :, nz // 2].sum())
69 mass_err = abs(flux_out - flux_in) / (abs(flux_in) + 1e-30)
70 bubble = bool((u[1:S, 0, nz // 2] < 0).any())
71 return dict(Re=Re, S=S, L=L, steps=steps, secs=time.time() - t0, xr_S=xr / S,
72 div=float(s.max_open_divergence()), mass_err=mass_err, bubble=bubble)