A channel at a prescribed flow rate
A pump delivers a fixed flow rate through a channel. What inlet pressure does it take? Stokes flow is usually driven by a pressure you choose; here the flow rate \(Q\) is fixed instead, and the inlet pressure that delivers it is one more unknown, a single number.

The speed of the computed velocity, with the profile \(u_x(y)\) at three stations, each a parabola peaking at \(1.5\,Q/H\).
The problem
Stokes flow in a channel of length \(L\) and height \(H\), no slip on the walls, a traction \(-P\,\mathbf n\) at the inlet with \(P\) unknown, and one extra equation for it:
The exact answer is the Poiseuille value \(P=12\,Q\,L/H^3\).
The jNO code
The inlet pressure is a constant unknown, and each test function comes from its own unknown:
u = d.unknown.vector(2, order=2) # Taylor-Hood velocity
p = d.unknown.scalar(name="p") # and pressure
P = d.unknown.scalar(constant=True, name="P_in") # the inlet pressure: one value
v, q, W = u.test(), p.test(), P.test()
P multiplies the inlet traction like any coefficient. Its test function W is one everywhere, so the flow-rate
term integrated over the inlet is the equation \(\int u_x\,dy=Q\):
fem = jno.fem(
[
ddot(grad(u), grad(v)) - p * div(v), # momentum
-q * div(u), # continuity
P * (-v.bind(x=xi, y=yi)[0]), # inlet traction -P n, with n = (-1, 0)
(u.bind(x=xi, y=yi)[0] - Q / H) * W, # the flow rate through the inlet: an integral row
u(xw, yw) - 0.0, # no slip
u(xi, yi)[1] - 0.0, # inflow normal to the inlet
]
)
Result
\(P=7.2\), the Poiseuille value, to round-off, on a \(6\times6\) mesh as on a \(32\times32\) one: the parabola and the linear pressure lie in the Taylor–Hood space, so they are exact.
Full script
The whole script, as it runs in the tests
"""A channel driven at a prescribed flow rate: the inlet pressure is a constant unknown.
-Δu + ∇p = 0, ∇·u = 0 on [0, L] x [0, H]
u = 0 on the walls, u_y = 0 on the inlet, a do-nothing outlet,
inlet traction -P n with P unknown, and ∫_inlet u_x dy = Q.
Closed form (Poiseuille, unit viscosity): P = 12 Q L / H³.
"""
import jax
import numpy as np
import jno
jax.config.update("jax_enable_x64", True) # the assembler builds in float64
run = jno.setup(__file__)
L, H, Q = 2.0, 1.0, 0.3
d = jno.shape.rect(0, 0, L, H).structured(n=32).domain()
x, y, _ = d.variable("interior", split=True)
xi, yi, _ = d.variable("left", split=True) # the inlet
xw, yw, _ = d.variable("walls", where=lambda x, y: (y < 1e-9) | (y > H - 1e-9), split=True)
u = d.unknown.vector(2, order=2) # Taylor-Hood velocity
p = d.unknown.scalar(name="p") # and pressure
P = d.unknown.scalar(constant=True, name="P_in") # the inlet pressure: one value
v, q, W = u.test(), p.test(), P.test()
grad = lambda w: jno.np.jacobian(w, [x, y])
div = lambda w: jno.np.trace(grad(w))
ddot = lambda a, b: jno.np.inner(a, b, n_contract=2)
fem = jno.fem(
[
ddot(grad(u), grad(v)) - p * div(v), # momentum
-q * div(u), # continuity
P * (-v.bind(x=xi, y=yi)[0]), # inlet traction -P n, with n = (-1, 0)
(u.bind(x=xi, y=yi)[0] - Q / H) * W, # the flow rate through the inlet: an integral row
u(xw, yw) - 0.0, # no slip
u(xi, yi)[1] - 0.0, # inflow normal to the inlet
]
)
sol = fem.solve(linear=jno.solve.lu()) # a bordered saddle system: solve it directly
P_in = float(np.asarray(sol)[fem.blocks[fem.block_index(P)]][0])
exact = 12 * Q * L / H**3
print(f"inlet pressure P = {P_in:.12f} Poiseuille 12 Q L / H^3 = {exact:.12f}")
assert abs(P_in - exact) < 1e-10