Modelintro
Prandtl mixing length model
Also called mixing length model.
An algebraic eddy viscosity equal to the square of a mixing length times the magnitude of the mean velocity gradient.
The Prandtl mixing length model is an algebraic turbulence closure that sets the eddy viscosity to , where is a prescribed mixing length and is the mean velocity gradient. It is the simplest way to apply the Boussinesq hypothesis to the Reynolds-averaged Navier-Stokes equations: it needs no extra transport equation, only a rule for , such as near a wall. The k-epsilon, k-omega, SST and Spalart-Allmaras models replace the prescribed length by transported quantities. The model predicts the logarithmic law of the wall, which wall functions then use.
The machine
Setting. A thin shear flow with mean velocity along a wall at , kinematic viscosity (m^2/s), and total shear stress per unit density. The wall stress is , the friction velocity is , and wall units are , , .
Closure. The Reynolds shear stress is
Mixing length. The model needs a rule for . Near a wall:
- , with the von Karman constant ;
- with van Driest damping, , with , which makes fall off like near the wall instead of .
In the outer part of a boundary layer, or in a free shear flow such as a jet or a wake, is a fixed fraction of the local layer width.
Parameters. and are fitted to measured mean velocity profiles; the outer fraction is fitted per flow type. What is derived: the form follows from dimensional reasoning once one length is given, and the log law follows from the model with no further input.
Equation in wall units. In the layer near a wall the mean momentum balance reduces to , or
This is a quadratic in with one root of the sign of :
This form avoids the loss of digits of the textbook root when is small. Integrating from the wall with gives the profile. For a constant stress layer ; for a channel of half-height , the exact balance of the RANS page gives with .
MIXING-LENGTH-PROFILE(y_max, n, κ, A+, τ+(·))- 1
h ← y_max / n; U_0 ← 0 - 2
for i ← 0 to n: y_i ← i h - 3
ℓ ← κ y_i (1 - exp(-y_i / A+)) - 4
g_i ← 2 τ+(y_i) / (1 + sqrt(1 + 4 ℓ^2 |τ+(y_i)|)) - 5
for i ← 1 to n: - 6
U_i ← U_(i-1) + h (g_(i-1) + g_i) / 2 - 7
return y, U
Line L4 is the stable root of the local balance, and line L6 is the trapezoidal rule, so the profile is second-order accurate in when is smooth. The cost is operations in the real RAM.
What it counts
The model gives the mean velocity profile , the eddy viscosity and the Reynolds shear stress, and from the profile the skin friction: the relation between and the velocity at a given height or the bulk velocity. It gives no turbulent kinetic energy and no normal stresses.
Relation to other models
- Closure hypothesis. The model is the Boussinesq hypothesis with the velocity scale and the length scale .
- Two-layer algebraic models. The Cebeci-Smith and Baldwin-Lomax models use the damped mixing length near the wall and a different outer formula, and were standard in aerodynamics before one- and two-equation models.
- Transport models. The k-epsilon model computes the length instead of prescribing it, and in a log layer in equilibrium it reduces to a mixing length . The Spalart-Allmaras model carries the eddy viscosity itself.
- Wall functions. Wall functions take the log law that this model predicts and impose it as a boundary condition for the other models.
- LES. The Smagorinsky model is a mixing length model for the subgrid scales, with set by the grid size and replaced by the magnitude of the resolved strain rate.
Known results in the model
Viscous sublayer (exact in the model). As , and , so to first order.
Log law (prediction of the model). For with and , the viscous term is small and , so
The slope comes out of the model. The constant depends on what happens near the wall, where the model has no physics, so it must be fitted.
Closed form with no damping (exact). With and the integral can be done:
For large it gives at . Values to check with a calculator: , , , . For example at , and , so the first term is ; the second is ; and .
Van Driest damping (computed, checked by the tests). With and , numerical integration gives , , , and , and at , and . So the damped model has . Measured values of are about 5.0 to 5.2, and the value 26 of was chosen to make the model fit them: the agreement is a fit, not a prediction.
Eddy viscosity by hand. In air, 1 cm from a wall where 1/s, the undamped model gives m and m^2/s, about 56 times the molecular value m^2/s.
Channel flow (computed). With at , the profile lies below the constant-stress one, and at the centerline because there. Measurements and DNS show a finite eddy viscosity at the centerline, so this zero is a known defect of the model.
Agreement with experiment (measurement). For attached boundary layers in weak pressure gradients, mixing length models with fitted outer constants give skin friction close to measurements. They do poorly for separated flows and for flows whose turbulence is not in local equilibrium, because responds instantly to the local gradient.
Code
Each implementation follows the pseudocode above. A comment @line links a line of code to a line of the pseudocode. Point at a line of the pseudocode to see the matching code. The build runs the native tests of each language.
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/mixing-length-model/. The authors are listed in prov/QA49H0.jsonl.
"""Prandtl mixing length model for the mean velocity near a wall, in wall units.
All quantities are in wall units: y+ = u_tau y / nu, U+ = U / u_tau, and the
total shear stress is tau+ = tau / (rho u_tau^2). The mean momentum balance is
(1 + nu_t+) dU+/dy+ = tau+(y+), nu_t+ = l+^2 |dU+/dy+|,
with the mixing length l+ = kappa y+ (times the van Driest damping factor
1 - exp(-y+ / A+) when A+ is given).
"""
import math
from typing import Callable, Optional
KAPPA = 0.41
def mixing_length(y_plus: float, kappa: float = KAPPA, a_plus: Optional[float] = None) -> float:
"""l+ = kappa y+, or kappa y+ (1 - exp(-y+ / A+)) with van Driest damping."""
damping = 1.0 if a_plus is None else 1.0 - math.exp(-y_plus / a_plus)
return kappa * y_plus * damping
def velocity_gradient(tau_plus: float, l_plus: float) -> float:
"""The root g of (1 + l+^2 |g|) g = tau+ that has the sign of tau+.
Written as 2 tau / (1 + sqrt(1 + 4 l^2 |tau|)) to avoid cancellation.
"""
return 2.0 * tau_plus / (1.0 + math.sqrt(1.0 + 4.0 * l_plus * l_plus * abs(tau_plus)))
def eddy_viscosity(y_plus: float, dudy_plus: float, kappa: float = KAPPA, a_plus: Optional[float] = None) -> float:
"""nu_t+ = l+^2 |dU+/dy+|."""
l = mixing_length(y_plus, kappa, a_plus)
return l * l * abs(dudy_plus)
def profile(
y_max: float,
n: int,
kappa: float = KAPPA,
a_plus: Optional[float] = None,
stress: Callable[[float], float] = lambda y: 1.0,
) -> tuple[list[float], list[float]]:
"""Mean velocity U+(y+) on the uniform grid y_i = i y_max / n, i = 0..n.
The gradient comes from the local momentum balance and is integrated
from the wall (U+ = 0 at y+ = 0) with the trapezoidal rule.
"""
if n < 1 or y_max <= 0:
raise ValueError("need n >= 1 and y_max > 0")
h = y_max / n # @line L1
u = [0.0] # @line L1
ys = [i * h for i in range(n + 1)] # @line L2
g = []
for y in ys: # @line L2
l = mixing_length(y, kappa, a_plus) # @line L3
g.append(velocity_gradient(stress(y), l)) # @line L4
for i in range(1, n + 1): # @line L5
u.append(u[-1] + 0.5 * h * (g[i - 1] + g[i])) # @line L6
return ys, u # @line L7
def channel_stress(re_tau: float) -> Callable[[float], float]:
"""Total shear stress tau+ = 1 - y+ / Re_tau of fully developed channel flow."""
return lambda y: 1.0 - y / re_tau
def exact_profile_no_damping(y_plus: float, kappa: float = KAPPA) -> float:
"""Closed form of U+ for l+ = kappa y+ and tau+ = 1.
U+ = asinh(2 kappa y) / kappa - (sqrt(1 + 4 kappa^2 y^2) - 1) / (2 kappa^2 y).
"""
if y_plus == 0:
return 0.0
s = math.sqrt(1.0 + 4.0 * kappa * kappa * y_plus * y_plus)
return math.asinh(2.0 * kappa * y_plus) / kappa - (s - 1.0) / (2.0 * kappa * kappa * y_plus)
def log_intercept_no_damping(kappa: float = KAPPA) -> float:
"""The limit of U+ - ln(y+) / kappa for l+ = kappa y+: (ln(4 kappa) - 1) / kappa."""
return (math.log(4.0 * kappa) - 1.0) / kappa
def log_intercept(y_max: float, n: int, kappa: float = KAPPA, a_plus: Optional[float] = None) -> float:
"""U+(y_max) - ln(y_max) / kappa from a constant stress profile."""
_, u = profile(y_max, n, kappa, a_plus)
return u[-1] - math.log(y_max) / kappa
test_mixing_length_model.py 75 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/mixing-length-model/. The authors are listed in prov/QA49H0.jsonl.
import math
import pytest
from mixing_length_model import (
KAPPA,
channel_stress,
eddy_viscosity,
exact_profile_no_damping,
log_intercept,
log_intercept_no_damping,
mixing_length,
profile,
velocity_gradient,
)
def test_gradient_solves_the_balance():
for tau in (1.0, 0.3, -0.7):
for l in (0.0, 0.5, 4.1, 100.0):
g = velocity_gradient(tau, l)
assert (1 + l * l * abs(g)) * g == pytest.approx(tau, rel=1e-12)
def test_mixing_length_and_damping():
assert mixing_length(10.0) == pytest.approx(4.1)
assert mixing_length(26.0, a_plus=26.0) == pytest.approx(0.41 * 26 * (1 - math.exp(-1)))
assert eddy_viscosity(100.0, 0.5) == pytest.approx(41.0**2 * 0.5)
def test_closed_form_limits():
# viscous sublayer: U+ = y+ + O(y+^3)
assert exact_profile_no_damping(0.01) == pytest.approx(0.01, rel=1e-4)
# log layer: the intercept tends to (ln(4 kappa) - 1) / kappa = -1.2324
b = log_intercept_no_damping()
assert b == pytest.approx(-1.232448, abs=1e-6)
y = 1e6
assert exact_profile_no_damping(y) - math.log(y) / KAPPA == pytest.approx(b, abs=1e-5)
def test_profile_matches_closed_form_with_second_order():
errs = []
for n in (250, 500, 1000, 2000):
ys, u = profile(100.0, n)
errs.append(abs(u[-1] - exact_profile_no_damping(100.0)))
assert errs[-1] < 1e-5
orders = [math.log2(errs[i] / errs[i + 1]) for i in range(len(errs) - 1)]
for p in orders:
assert abs(p - 2.0) < 0.2
def test_van_driest_log_law_constant():
# with A+ = 26 and kappa = 0.41 the constant stress profile has B near 5.28
b = log_intercept(1000.0, 40000, a_plus=26.0)
assert 5.26 < b < 5.30
ys, u = profile(1.0, 100, a_plus=26.0)
assert u[-1] == pytest.approx(1.0, abs=1e-3) # linear sublayer
def test_channel_profile_below_constant_stress():
re_tau = 180.0
_, u_const = profile(re_tau, 3600, a_plus=26.0)
_, u_chan = profile(re_tau, 3600, a_plus=26.0, stress=channel_stress(re_tau))
assert u_chan[-1] < u_const[-1]
assert all(b >= a for a, b in zip(u_chan, u_chan[1:]))
# the gradient is zero at the centerline, where the stress vanishes
assert velocity_gradient(channel_stress(re_tau)(re_tau), 50.0) == 0.0
def test_bad_input():
with pytest.raises(ValueError):
profile(0.0, 10)
References
- Ludwig Prandtl, Bericht über Untersuchungen zur ausgebildeten Turbulenz, Zeitschrift für Angewandte Mathematik und Mechanik 5(2), 1925, 136-139, the mixing length and the eddy viscosity proportional to its square times the velocity gradient
- E. R. van Driest, On turbulent flow near a wall, Journal of the Aeronautical Sciences 23(11), 1956, 1007-1011, the exponential damping factor with the constant A+ = 26
- Stephen B. Pope, Turbulent Flows, Cambridge University Press, 2000, Section 7.1.4 (mean velocity profiles and the log law), Section 7.1.7 (lengthscales and the mixing length) and Section 10.2.2 (the mixing-length model)
- David C. Wilcox, Turbulence Modeling for CFD, third edition, DCW Industries, 2006, Chapter 3 (algebraic models, the mixing length and the van Driest damping)
Where this leads
About this page
The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H0 no proof |
|
| Lean | L0 no Lean part |
|
| Code (python) | I0 not checked yet |
|
| Visual | V0 none |
|
| Writing | W4 complete |
|
Tag QA49H0 Edit this page History Report an error Markdown