12. Start-up of viscoelastic channel flow: the Waters–King solution and Brownian configuration fields
When a pressure gradient is applied suddenly to a Newtonian fluid at rest in a channel, the centreline velocity rises monotonically to its steady value. In a polymer solution with a large elasticity number, , it overshoots the steady value and oscillates before it settles. Waters and King (1970) solved this problem exactly for the Oldroyd-B fluid, and their solution is a demanding test of a time-dependent viscoelastic solver.
The second subject of the lecture is the coupling of a flow calculation to a stochastic simulation of the polymer, without a constitutive equation. If each cell has its own independent ensemble (the CONNFFESSIT approach of Laso and Öttinger, 1993), the statistical error of the stress differs from cell to cell, and its derivative, which enters the momentum equation, is very noisy. The Brownian configuration fields of Hulsen, van Heel and van den Brule (1997) use the same random numbers in all cells, which makes the stress smooth in space.
Learning objectives¶
Write the start-up of plane Poiseuille flow in dimensionless form, with the elasticity number and the viscosity ratio .
Evaluate the Waters–King solution and find when its modes oscillate.
Compare a finite-volume solver of the Oldroyd-B equations with the Waters–King solution.
Compare Brownian configuration fields with independent ensembles, for Hookean and for FENE dumbbells.
Time: about 60 min
try: # use the installed package, or the copy in this repository
import engcomprheo
except ImportError:
import pathlib, subprocess, sys
for _root in [pathlib.Path.cwd(), *pathlib.Path.cwd().parents]:
if (_root / "engcomprheo" / "__init__.py").exists():
sys.path.insert(0, str(_root))
break
else: # on Google Colab: install from GitHub
subprocess.run([sys.executable, "-m", "pip", "install", "-q",
"git+https://github.com/ktwyw/engcomprheo.git"], check=True)
import engcomprheo
import inspect
import math
import numpy as np
import matplotlib.pyplot as plt
from engcomprheo import (brownian_chains, constants_benchmarks, entangled_tubes, mesoscopic_suspensions_dpd,
microrheology_rheoml, shear_banding_instabilities, tensors_kinematics,
viscoelastic_fvm_2d, viscoplastic_admm)
from engcomprheo.plotting import label_panels, log_ticks, panel_label, use_style
use_style()
trapezoid = getattr(np, "trapezoid", None) or np.trapz # NumPy 2 renamed trapz to trapezoid
def show_source(obj):
"""Return the source code of a function or class of the package."""
return inspect.getsource(obj)
def heading(text):
print(f"\n{text}\n" + "=" * len(text))1. Start-up of channel flow and the Waters–King solution¶
Consider the flow of an Oldroyd-B fluid in a plane channel, , which starts from rest (, ) when the pressure gradient is applied:
In this parallel flow the convective terms of the equation for vanish (), so that the problem for the velocity and the shear stress is linear. The normal stress follows from and is quadratic in the shear rate.
With scaled by , by the steady centreline velocity , where , and by the viscous time , the problem contains two dimensionless groups, which do not depend on :
Waters and King (1970) expanded the difference between the steady and the current velocity in modes that vanish at the walls, with . Eliminating gives the equation of a damped oscillator for each mode:
A mode oscillates when its discriminant is negative. Shear waves then travel between the walls with a speed of order , and the centreline velocity overshoots its steady value and oscillates with decreasing amplitude.
heading("Demonstration 1: the Waters-King solution for several elasticity numbers")
y_wk = np.linspace(-1.0, 1.0, 49)
t_wk = np.linspace(0.0, 12.0, 241)
el_cases = [0.0, 0.35, 1.20, 4.00] # Since rho=1, H=1, eta_0=1 -> El == lam
wk_runs = {}
for lam_v in el_cases:
wk_runs[lam_v] = constants_benchmarks.waters_king_startup_poiseuille(
y_wk, t_wk, dpdx_neg=2.0, H_half=1.0, rho=1.0, eta_s=0.10, eta_p=0.90, lam=lam_v
)
uc = wk_runs[lam_v]["u_centerline"]
u_inf = wk_runs[lam_v]["u_centerline_steady"]
print(
f"El = {wk_runs[lam_v]['elasticity_number']:4.2f} | "
f"peak u(0,t)/U_inf = {np.max(uc)/u_inf:.4f} | "
f"post-peak min/U_inf = {np.min(uc[np.argmax(uc):])/u_inf:.4f}"
)
# Compute microchannel Elasticity number of benchmark Boger PIB fluid in H = 1 mm slit:
boger = constants_benchmarks.BENCHMARK_FLUIDS_DB["BOGER_PIB"]
eta0_boger = boger["eta_s_Pas"] + boger["eta_p_Pas"]
el_boger_1mm = boger["lam_s"] * eta0_boger / (boger["rho_kgm3"] * (1.0e-3 ** 2))
print(f"BOGER_PIB at H = 1.0 mm: El = {el_boger_1mm:.1f} (elasticity dominates inertia)")
assert np.max(wk_runs[0.0]["u_centerline"]) <= wk_runs[0.0]["u_centerline_steady"] + 1e-9
assert np.max(wk_runs[1.20]["u_centerline"]) > 1.25 * wk_runs[1.20]["u_centerline_steady"]
assert np.max(wk_runs[4.00]["u_centerline"]) > np.max(wk_runs[1.20]["u_centerline"])
assert el_boger_1mm > 1000.0
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(10.8, 4.1))
colors = ["#6B7280", "#0F766E", "#E08214", "#7B4FA3"]
for lam_v, col in zip(el_cases, colors):
lbl = "Newtonian (El = 0)" if lam_v == 0.0 else f"Oldroyd-B (El = {lam_v:.2f})"
ls = "--" if lam_v == 0.0 else "-"
ax1.plot(t_wk, wk_runs[lam_v]["u_centerline"], color=col, lw=2.1, ls=ls, label=lbl)
ax1.axhline(1.0, color="black", lw=1.0, ls=":", label="Steady Poiseuille $U_\\infty$")
ax1.set_xlabel("Time t [s, viscous units]")
ax1.set_ylabel("Centreline velocity u(0, t) / $U_\\infty$")
ax1.set_title(r"Centreline velocity ($\beta_s = 0.1$)")
ax1.legend(fontsize=8.2)
snap_times = [0.25, 0.75, 1.35, 2.25, 11.5]
for ts in snap_times:
idx = int(np.argmin(np.abs(t_wk - ts)))
ax2.plot(wk_runs[1.20]["u_yt"][idx], y_wk, lw=2.0, label=f"t = {t_wk[idx]:.2f}")
ax2.plot(wk_runs[1.20]["u_steady"], y_wk, "k--", lw=1.4, label="Exact parabola $u_\\infty$(y)")
ax2.set_xlabel("Axial velocity u(y, t)")
ax2.set_ylabel("Position y / H")
ax2.set_title(r"Velocity profiles ($\mathrm{El} = 1.2$)")
ax2.legend(fontsize=8.0)
label_panels(fig)
plt.show()
Demonstration 1: the Waters-King solution for several elasticity numbers
========================================================================
El = 0.00 | peak u(0,t)/U_inf = 1.0000 | post-peak min/U_inf = 1.0000
El = 0.35 | peak u(0,t)/U_inf = 1.1923 | post-peak min/U_inf = 0.9795
El = 1.20 | peak u(0,t)/U_inf = 1.8394 | post-peak min/U_inf = 0.7724
El = 4.00 | peak u(0,t)/U_inf = 2.8453 | post-peak min/U_inf = 0.3612
BOGER_PIB at H = 1.0 mm: El = 1516.9 (elasticity dominates inertia)

Figure 12.1. Exact start-up of plane Poiseuille flow of an Oldroyd-B fluid. (a) Centreline velocity divided by its steady value for four elasticity numbers. (b) Velocity profiles at five times for , with the steady parabola.
2. A finite-volume solver on a staggered grid¶
Demonstration 1 shows how elasticity changes the start-up of the flow. At the velocity obeys a diffusion equation, and the centreline velocity cannot exceed its steady value, . For at the equations behave as a damped wave equation, and the velocity overshoots the steady profile before it settles.
The function viscoelastic_fvm_2d.solve_1d_channel_viscoelastic_startup solves the same problem numerically, also for models that are not linear, on a staggered grid, which avoids a decoupling of velocity and stress between neighbouring points:
The velocity is stored at the cell faces , with at the walls.
The polymer stresses are stored at the cell centres. The velocity gradient and the derivative of the stress are then central differences of second order.
The solvent term is implicit and is inverted with the discrete sine transform, which removes the restriction of an explicit scheme.
heading("Demonstration 2: the finite-volume solver against the Waters-King solution")
pde_run = viscoelastic_fvm_2d.solve_1d_channel_viscoelastic_startup(
ny=40, t_end=6.5, dt=0.006, dpdx_neg=2.0, H_half=1.0, rho=1.0, eta_s=0.20, eta_p=0.80, lam=1.0, method="oldroyd_b_pde"
)
wk_oracle = constants_benchmarks.waters_king_startup_poiseuille(
pde_run["y_nodes"], pde_run["t"], dpdx_neg=2.0, H_half=1.0, rho=1.0, eta_s=0.20, eta_p=0.80, lam=1.0
)
rel_l2_u = float(np.linalg.norm(pde_run["u_centerline_hist"] - wk_oracle["u_centerline"]) / np.linalg.norm(wk_oracle["u_centerline"]))
y_c = pde_run["y_cells"]
# Steady analytical shear rate du/dy = -(G_p / eta_0) * y = -2*y -> tau_p,xy = -eta_p * 2 * y, N1 = 2 * eta_p * lam * (2*y)^2:
tau_xy_exact = -0.80 * 2.0 * y_c
n1_exact = 2.0 * 0.80 * 1.0 * ((-2.0 * y_c) ** 2)
err_tau = float(np.max(np.abs(pde_run["tau_xy_final"] - tau_xy_exact)))
err_n1 = float(np.max(np.abs(pde_run["N1_final"] - n1_exact)))
print(f"Transient centreline relative L2 error against Waters-King : {rel_l2_u:.5f}")
print(f"Final polymer shear stress max error |tau_xy - exact| : {err_tau:.5f}")
print(f"Final normal stress difference max error |N1 - exact| : {err_n1:.5f}")
assert rel_l2_u < 0.015
assert err_tau < 0.05
assert err_n1 < 0.25
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(10.8, 4.0))
ax1.plot(wk_oracle["t"], wk_oracle["u_centerline"], color="#1F2933", lw=2.3, label="Waters and King (1970) exact")
ax1.plot(pde_run["t"][::25], pde_run["u_centerline_hist"][::25], "o", ms=4.5, color="#C0392B", label="Finite-volume solver (ny=48)")
ax1.set_xlabel("Time t [s]")
ax1.set_ylabel("Centreline velocity u(0, t)")
ax1.set_title(r"Centreline velocity")
ax1.legend(fontsize=8.3)
ax2.plot(y_c, tau_xy_exact, "k--", lw=1.6, label="Exact steady $\\tau_{p,xy}$(y)")
ax2.plot(y_c[::2], pde_run["tau_xy_final"][::2], "s", ms=4.2, color="#0F766E", label="FVM $\\tau_{p,xy}$(y, t=8)")
ax2.plot(y_c, n1_exact, color="#6B7280", ls=":", lw=1.8, label="Exact steady $N_1(y) = 2\\eta_p\\lambda\\dot{\\gamma}^2$")
ax2.plot(y_c[::2], pde_run["N1_final"][::2], "^", ms=4.5, color="#E08214", label="FVM $N_1$(y, t=8)")
ax2.set_xlabel("Position y / H")
ax2.set_ylabel("Polymer stress components")
ax2.set_title(r"Polymer stresses at $t = 8$")
ax2.legend(fontsize=7.9)
label_panels(fig)
plt.show()
Demonstration 2: the finite-volume solver against the Waters-King solution
==========================================================================
Transient centreline relative L2 error against Waters-King : 0.00079
Final polymer shear stress max error |tau_xy - exact| : 0.00673
Final normal stress difference max error |N1 - exact| : 0.00290

Figure 12.2. The finite-volume solver against the exact solution. (a) Centreline velocity; the relative error is 0.08 %. (b) Polymer shear stress and first normal stress difference across the channel against the steady values.
3. Coupling to stochastic simulations: configuration fields and independent ensembles¶
For models such as the FENE dumbbell no exact constitutive equation exists, and a closure such as FENE-P introduces errors in fast start-up flows (Lecture 6). A micro–macro method avoids the constitutive equation: it simulates connector vectors in each cell of the flow calculation and passes the Kramers stress to the momentum equation. There are two ways to choose the random numbers:
Independent ensembles (CONNFFESSIT; Laso and Öttinger, 1993). Each cell has its own ensemble with its own random increments . The statistical errors of neighbouring cells, , are then uncorrelated, and the error of the derivative is of order , which grows as the grid is refined.
Brownian configuration fields (Hulsen, van Heel and van den Brule, 1997). The ensemble consists of fields , each uniform in at the start and each driven by a random increment that is the same at all positions ():
Because neighbouring cells receive the same random increment, a field varies in space only through the velocity gradient , which is smooth. The noise of the derivative of the stress is smaller by more than a factor of ten.
heading("Demonstration 3: configuration fields against independent ensembles of the same size")
common_kw = dict(ny=32, t_end=3.5, dt=0.005, dpdx_neg=2.0, H_half=1.0, rho=1.0, eta_s=0.25, eta_p=0.75, lam=0.80)
ref_pde = viscoelastic_fvm_2d.solve_1d_channel_viscoelastic_startup(**common_kw, method="oldroyd_b_pde")
bcf_hk = viscoelastic_fvm_2d.solve_1d_channel_viscoelastic_startup(**common_kw, method="bcf_hookean", n_fields=450, seed=21)
con_hk = viscoelastic_fvm_2d.solve_1d_channel_viscoelastic_startup(**common_kw, method="connfessit_hookean", n_fields=450, seed=21)
rough_ratio = con_hk["spatial_stress_roughness"] / max(bcf_hk["spatial_stress_roughness"], 1e-12)
err_bcf = float(np.linalg.norm(bcf_hk["u_centerline_hist"] - ref_pde["u_centerline_hist"]) / np.linalg.norm(ref_pde["u_centerline_hist"]))
print(f"BCF Hookean centreline error against exact PDE : {err_bcf:.4f}")
print(f"BCF spatial stress curvature roughness ||d2tau||: {bcf_hk['spatial_stress_roughness']:.4f}")
print(f"CONNFFESSIT spatial stress roughness ||d2tau|| : {con_hk['spatial_stress_roughness']:.4f}")
print(f"Roughness suppression factor (CONNFFESSIT / BCF): {rough_ratio:.1f}x")
assert err_bcf < 0.06
assert rough_ratio > 10.0
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(10.8, 4.0))
ax1.plot(ref_pde["t"], ref_pde["u_centerline_hist"], "k-", lw=2.3, label="Exact Oldroyd-B PDE")
ax1.plot(con_hk["t"], con_hk["u_centerline_hist"], color="#E08214", lw=1.3, alpha=0.85, label="Independent ensembles (Nf=450)")
ax1.plot(bcf_hk["t"][::18], bcf_hk["u_centerline_hist"][::18], "o", ms=4.3, color="#2166AC", label="Configuration fields (Nf=450)")
ax1.set_xlabel("Time t [s]")
ax1.set_ylabel("Centreline velocity u(0, t)")
ax1.set_title(r"Centreline velocity")
ax1.legend(fontsize=8.0)
ax2.plot(con_hk["y_cells"], con_hk["tau_xy_final"], color="#E08214", lw=1.5, marker="x", ms=4.2, label=f"Independent ensembles (roughness = {con_hk['spatial_stress_roughness']:.1f})")
ax2.plot(bcf_hk["y_cells"], bcf_hk["tau_xy_final"], color="#2166AC", lw=2.3, label=f"Configuration fields (roughness = {bcf_hk['spatial_stress_roughness']:.2f})")
ax2.plot(ref_pde["y_cells"], ref_pde["tau_xy_final"], "k--", lw=1.4, label="Exact Oldroyd-B PDE")
ax2.set_xlabel("Position y / H")
ax2.set_ylabel("Polymer shear stress $\\tau_{p,xy}(y, t_{\\mathrm{end}})$")
ax2.set_title(r"Polymer shear stress across the channel")
ax2.legend(fontsize=7.9)
label_panels(fig)
plt.show()
Demonstration 3: configuration fields against independent ensembles of the same size
====================================================================================
BCF Hookean centreline error against exact PDE : 0.0466
BCF spatial stress curvature roughness ||d2tau||: 0.0299
CONNFFESSIT spatial stress roughness ||d2tau|| : 17.3791
Roughness suppression factor (CONNFFESSIT / BCF): 581.4x

Figure 12.3. Micro–macro start-up with 450 Hookean dumbbells per cell. (a) Centreline velocity with configuration fields and with independent ensembles, against the Oldroyd-B solver. (b) Polymer shear stress at the end: smooth with configuration fields, noisy with independent ensembles.
4. Start-up with FENE configuration fields¶
For Hookean dumbbells the configuration fields reproduce the Oldroyd-B model, for which a constitutive equation exists. The method becomes useful when the linear spring is replaced by the FENE spring, . The fields are then advanced with the semi-implicit step of Lecture 3 (brownian_chains.solve_fene_cubic_radial), which keeps for any time step.
With a large pressure gradient () the shear rate at the walls exceeds :
Near the walls the finite extensibility limits the stretch of the dumbbells, and the polymer viscosity is lower than at rest, .
With less resistance at the walls, the steady velocity in the centre is higher than for the Oldroyd-B fluid, and the overshoot is smaller. No closure approximation is involved.
heading("Demonstration 4: FENE configuration fields for several values of b")
fene_kw = dict(ny=24, t_end=3.2, dt=0.006, dpdx_neg=3.2, H_half=1.0, rho=1.0, eta_s=0.25, eta_p=0.75, lam=0.80, n_fields=160, seed=19)
bcf_inf = viscoelastic_fvm_2d.solve_1d_channel_viscoelastic_startup(**fene_kw, method="bcf_hookean")
b_list = [12.0, 30.0, 100.0]
fene_runs = {b_v: viscoelastic_fvm_2d.solve_1d_channel_viscoelastic_startup(**fene_kw, method="bcf_fene", b_fene=b_v) for b_v in b_list}
print(f"Hookean BCF (b -> inf) : u_c(t_end) = {bcf_inf['u_centerline_hist'][-1]:.4f}, wall |tau_xy| = {abs(bcf_inf['tau_xy_final'][0]):.4f}")
for b_v in b_list:
r = fene_runs[b_v]
print(f"FENE BCF (b = {b_v:5.1f}) : u_c(t_end) = {r['u_centerline_hist'][-1]:.4f}, wall |tau_xy| = {abs(r['tau_xy_final'][0]):.4f}")
# Tighter finite extensibility (smaller b) thins polymer shear stress at the wall and boosts centerline speed:
assert fene_runs[12.0]["u_centerline_hist"][-1] > fene_runs[30.0]["u_centerline_hist"][-1] > bcf_inf["u_centerline_hist"][-1]
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(10.8, 4.0))
cols_b = {12.0: "#C0392B", 30.0: "#E08214", 100.0: "#0F766E"}
for b_v in b_list:
ax1.plot(fene_runs[b_v]["t"], fene_runs[b_v]["u_centerline_hist"], color=cols_b[b_v], lw=2.1, label=f"FENE fields (b = {b_v:.0f})")
ax1.plot(bcf_inf["t"], bcf_inf["u_centerline_hist"], "k--", lw=1.9, label="Hookean fields")
ax1.set_xlabel("Time t [s]")
ax1.set_ylabel("Centreline velocity u(0, t)")
ax1.set_title(r"Centreline velocity")
ax1.legend(fontsize=8.1)
for b_v in b_list:
ax2.plot(fene_runs[b_v]["u_final"], fene_runs[b_v]["y_nodes"], color=cols_b[b_v], lw=2.1, label=f"FENE b = {b_v:.0f}")
ax2.plot(bcf_inf["u_final"], bcf_inf["y_nodes"], "k--", lw=1.8, label="Hookean limit")
ax2.set_xlabel("Velocity $u(y, t_{\\mathrm{end}})$")
ax2.set_ylabel("Position y / H")
ax2.set_title(r"Final velocity profiles")
ax2.legend(fontsize=8.1)
label_panels(fig)
plt.show()
Demonstration 4: FENE configuration fields for several values of b
==================================================================
Hookean BCF (b -> inf) : u_c(t_end) = 1.6399, wall |tau_xy| = 2.3548
FENE BCF (b = 12.0) : u_c(t_end) = 2.4659, wall |tau_xy| = 2.3403
FENE BCF (b = 30.0) : u_c(t_end) = 2.1479, wall |tau_xy| = 2.1724
FENE BCF (b = 100.0) : u_c(t_end) = 1.8609, wall |tau_xy| = 2.1629

Figure 12.4. Configuration fields with FENE dumbbells for three values of , and with Hookean dumbbells. (a) Centreline velocity. (b) Velocity profiles at the end of the run.
Inside the algorithm: the modes of the Waters–King solution¶
The cell below prints the source of constants_benchmarks.waters_king_startup_poiseuille and evaluates the solution independently in NumPy, to check each kind of mode: overdamped (), critically damped () and oscillating ().
Check against the package¶
For each mode the initial amplitude is the Fourier coefficient of the steady profile . Because the polymer stress is zero at the start, the initial rate of change is ; the cell checks this with assert np.allclose(..., atol=1e-13). For large , and , : the solvent viscosity damps the modes of short wavelength, while the modes of long wavelength oscillate.
heading("Inside the algorithm: the modes of the Waters-King solution")
print(show_source(constants_benchmarks.waters_king_startup_poiseuille))
# This solver, NumPy implementation of Waters & King (1970) planar startup:
y_chk = np.linspace(-1.0, 1.0, 33)
t_chk = np.linspace(0.0, 6.0, 61)
Gp, Hh, rho_v, es, ep, lam_v = 2.4, 1.0, 1.1, 0.15, 0.85, 1.3
eta0 = es + ep
u_inf_chk = (Gp / (2.0 * eta0)) * (Hh**2 - y_chk**2)
m_idx = np.arange(80, dtype=float)
k_m = (2.0 * m_idx + 1.0) * np.pi / (2.0 * Hh)
sgn = np.where((np.arange(80) % 2) == 0, 1.0, -1.0)
w0 = (Gp / eta0) * (2.0 * sgn / (Hh * k_m**3))
v0 = -(eta0 * k_m**2 / rho_v) * w0
a_c = rho_v * lam_v
b_c = rho_v + lam_v * es * (k_m**2)
c_c = eta0 * (k_m**2)
disc = b_c**2 - 4.0 * a_c * c_c
gam = b_c / (2.0 * a_c)
W_mat = np.zeros((t_chk.size, k_m.size))
for j in range(k_m.size):
if disc[j] < 0.0:
om = math.sqrt(-disc[j]) / (2.0 * a_c)
W_mat[:, j] = np.exp(-gam[j] * t_chk) * (w0[j] * np.cos(om * t_chk) + ((v0[j] + gam[j] * w0[j]) / om) * np.sin(om * t_chk))
else:
om = math.sqrt(disc[j]) / (2.0 * a_c)
W_mat[:, j] = 0.5 * ((w0[j] + (v0[j] + gam[j] * w0[j]) / om) * np.exp((-gam[j] + om) * t_chk) + (w0[j] - (v0[j] + gam[j] * w0[j]) / om) * np.exp((-gam[j] - om) * t_chk))
u_standalone = u_inf_chk[None, :] - W_mat @ np.cos(k_m[:, None] * y_chk[None, :])
u_standalone[0, :] = 0.0
u_standalone[:, [0, -1]] = 0.0
lib_wk = constants_benchmarks.waters_king_startup_poiseuille(y_chk, t_chk, dpdx_neg=Gp, H_half=Hh, rho=rho_v, eta_s=es, eta_p=ep, lam=lam_v, n_modes=80)
max_diff = float(np.max(np.abs(u_standalone - lib_wk["u_yt"])))
n_underdamped = int(np.sum(disc < 0.0))
print(f"Number of underdamped viscoelastic Fourier modes (disc < 0): {n_underdamped} / 80")
print(f"Max pointwise discrepancy against engcomprheo Waters-King : {max_diff:.3e}")
assert np.allclose(u_standalone, lib_wk["u_yt"], atol=1e-13)
Inside the algorithm: the modes of the Waters-King solution
===========================================================
def waters_king_startup_poiseuille(
y_grid: np.ndarray,
t_vals: np.ndarray,
dpdx_neg: float = 2.0,
H_half: float = 1.0,
rho: float = 1.0,
eta_s: float = 0.2,
eta_p: float = 0.8,
lam: float = 0.8,
n_modes: int = 80,
) -> dict:
"""Start-up of plane Poiseuille flow of an Oldroyd-B fluid: the series solution of Waters and King (1970)."""
y = np.asarray(y_grid, dtype=float).ravel()
t = np.asarray(t_vals, dtype=float).ravel()
if H_half <= 0.0 or rho <= 0.0 or eta_s < 0.0 or eta_p < 0.0 or (eta_s + eta_p) <= 0.0 or lam < 0.0:
raise ValueError("Require H_half > 0, rho > 0, non-negative viscosities with eta_0 > 0, and lam >= 0.")
if np.any(t < 0.0) or np.any(np.abs(y) > H_half + 1e-12):
raise ValueError("Require t >= 0 and y in [-H_half, +H_half].")
eta_0 = float(eta_s + eta_p)
u_steady = (float(dpdx_neg) / (2.0 * eta_0)) * (H_half**2 - y**2)
n_idx = np.arange(int(n_modes), dtype=float)
k_n = (2.0 * n_idx + 1.0) * math.pi / (2.0 * H_half) # (M,)
sign_n = np.where((np.arange(int(n_modes)) % 2) == 0, 1.0, -1.0)
a_fourier = 2.0 * sign_n / (H_half * (k_n**3)) # Fourier coeffs of (H^2 - y^2)/2
w0_n = (float(dpdx_neg) / eta_0) * a_fourier
dw0_n = -(eta_0 * (k_n**2) / float(rho)) * w0_n
# Mode amplitude matrix W_modes of shape (T, M):
w_modes = np.zeros((t.size, k_n.size), dtype=float)
if lam <= 1e-14:
decay = (eta_0 * (k_n**2)) / float(rho)
w_modes = w0_n[None, :] * np.exp(-t[:, None] * decay[None, :])
else:
a_c = float(rho * lam)
b_c = float(rho) + float(lam * eta_s) * (k_n**2)
c_c = eta_0 * (k_n**2)
disc = b_c**2 - 4.0 * a_c * c_c
gamma_damp = b_c / (2.0 * a_c)
for m in range(k_n.size):
gm = gamma_damp[m]
w0 = w0_n[m]
v0 = dw0_n[m]
dm = disc[m]
if dm > 1e-18:
om = math.sqrt(dm) / (2.0 * a_c)
c1 = 0.5 * (w0 + (v0 + gm * w0) / om)
c2 = 0.5 * (w0 - (v0 + gm * w0) / om)
w_modes[:, m] = c1 * np.exp((-gm + om) * t) + c2 * np.exp((-gm - om) * t)
elif dm < -1e-18:
om = math.sqrt(-dm) / (2.0 * a_c)
w_modes[:, m] = np.exp(-gm * t) * (w0 * np.cos(om * t) + ((v0 + gm * w0) / om) * np.sin(om * t))
else:
w_modes[:, m] = np.exp(-gm * t) * (w0 + (v0 + gm * w0) * t)
cos_ky = np.cos(k_n[:, None] * y[None, :]) # (M, Y)
u_yt = u_steady[None, :] - (w_modes @ cos_ky) # (T, Y)
# Enforce exact t == 0 zero velocity without Gibbs truncation ripple:
u_yt[t == 0.0, :] = 0.0
u_yt[:, np.isclose(np.abs(y), H_half)] = 0.0
el_num = float(lam * eta_0 / (rho * (H_half**2)))
beta_ratio = float(eta_s / eta_0)
return {
"y": y,
"t": t,
"u_yt": u_yt,
"u_steady": u_steady,
"u_centerline": u_yt[:, int(np.argmin(np.abs(y)))],
"u_centerline_steady": float(dpdx_neg * (H_half**2) / (2.0 * eta_0)),
"elasticity_number": el_num,
"beta_viscosity_ratio": beta_ratio,
}
Number of underdamped viscoelastic Fourier modes (disc < 0): 4 / 80
Max pointwise discrepancy against engcomprheo Waters-King : 0.000e+00
Exercises¶
Worked solutions are in 12_solutions.ipynb. The cell below the list is a short self-check to start from.
Verify a result. The lowest mode of the Waters–King solution, with wavenumber , oscillates when is negative, where . Find the two roots of and plot them for . Check with
waters_king_startup_poiseuilleat that the centreline velocity is monotonic for an elasticity number below and exceeds its steady value for one between the two roots.Find how it fails. Compare independent ensembles in each cell (the CONNFFESSIT approach) with Brownian configuration fields at a fixed ensemble size on grids of cells (
t_end=2.2, dt=0.006). Compute the roughness of the stress profile (spatial_stress_roughness, the norm of ) and the root-mean-square error of , the force that enters the momentum equation, relative to the solution of the Oldroyd-B equation.Implement it yourself. Write a solver in NumPy for start-up of channel flow with Hookean configuration fields: assemble the tridiagonal matrix of the implicit solvent term, and advance fields in antithetic pairs with random increments that are uniform in space. Compare with
solve_1d_channel_viscoelastic_startup, with which it should agree to rounding error, and withwaters_king_startup_poiseuille.
heading("Self-check for the exercises")
assert engcomprheo.__version__ == "1.0.0"
assert np.max(wk_runs[4.00]["u_centerline"]) > 1.35 * wk_runs[4.00]["u_centerline_steady"]
assert rel_l2_u < 0.015
assert rough_ratio > 10.0
assert fene_runs[12.0]["u_centerline_hist"][-1] > bcf_inf["u_centerline_hist"][-1]
print("All checks passed.")
Self-check for the exercises
============================
All checks passed.