Algorithm Search⌘K

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 νt=ℓm2∣dU/dy∣\nu_t = \ell_m^2 |dU/dy|, where ℓm\ell_m is a prescribed mixing length and dU/dydU/dy 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 ℓm\ell_m, such as ℓm=κy\ell_m = \kappa y 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 U(y)U(y) along a wall at y=0y = 0, kinematic viscosity ν\nu (m^2/s), and total shear stress τ(y)\tau(y) per unit density. The wall stress is τw\tau_w, the friction velocity is uτ=τw/ρu_\tau = \sqrt{\tau_w/\rho}, and wall units are y+=uτy/νy^+ = u_\tau y / \nu, U+=U/uτU^+ = U/u_\tau, τ+=τ/(ρuτ2)\tau^+ = \tau/(\rho u_\tau^2).

Closure. The Reynolds shear stress is

−⟨u′v′⟩=νtdUdy,νt=ℓm2∣dUdy∣.-\langle u'v' \rangle = \nu_t \frac{dU}{dy}, \qquad \nu_t = \ell_m^2 \left|\frac{dU}{dy}\right|.

Mixing length. The model needs a rule for ℓm\ell_m. Near a wall:

  • ℓm=κy\ell_m = \kappa y, with the von Karman constant κ≈0.41\kappa \approx 0.41;
  • with van Driest damping, ℓm=κy(1−e−y+/A+)\ell_m = \kappa y\left(1 - e^{-y^+/A^+}\right), with A+=26A^+ = 26, which makes νt\nu_t fall off like y4y^4 near the wall instead of y2y^2.

In the outer part of a boundary layer, or in a free shear flow such as a jet or a wake, ℓm\ell_m is a fixed fraction of the local layer width.

Parameters. κ\kappa and A+A^+ are fitted to measured mean velocity profiles; the outer fraction is fitted per flow type. What is derived: the form ℓ2∣dU/dy∣\ell^2|dU/dy| 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 (ν+νt) dU/dy=τ(\nu + \nu_t)\, dU/dy = \tau, or

(1+ℓ+2∣g∣) g=τ+,g=dU+dy+.(1 + \ell^{+2} |g|)\, g = \tau^+, \qquad g = \frac{dU^+}{dy^+}.

This is a quadratic in gg with one root of the sign of τ+\tau^+:

g=2τ+1+1+4ℓ+2∣τ+∣.g = \frac{2\tau^+}{1 + \sqrt{1 + 4\ell^{+2}|\tau^+|}}.

This form avoids the loss of digits of the textbook root (−1+⋯)/(2ℓ+2)(-1 + \sqrt{\cdots})/(2\ell^{+2}) when ℓ+\ell^+ is small. Integrating gg from the wall with U+(0)=0U^+(0) = 0 gives the profile. For a constant stress layer τ+=1\tau^+ = 1; for a channel of half-height δ\delta, the exact balance of the RANS page gives τ+=1−y+/Reτ\tau^+ = 1 - y^+/Re_\tau with Reτ=uτδ/νRe_\tau = u_\tau \delta/\nu.

  1. MIXING-LENGTH-PROFILE(y_max, n, κ, A+, τ+(·))
  2. 1h ← y_max / n; U_0 ← 0
  3. 2for i ← 0 to n: y_i ← i h
  4. 3ℓ ← κ y_i (1 - exp(-y_i / A+))
  5. 4g_i ← 2 τ+(y_i) / (1 + sqrt(1 + 4 ℓ^2 |τ+(y_i)|))
  6. 5for i ← 1 to n:
  7. 6U_i ← U_(i-1) + h (g_(i-1) + g_i) / 2
  8. 7return 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 hh when gg is smooth. The cost is O(n)O(n) operations in the real RAM.

What it counts

The model gives the mean velocity profile U(y)U(y), the eddy viscosity νt(y)\nu_t(y) and the Reynolds shear stress, and from the profile the skin friction: the relation between uτu_\tau 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 ℓm∣dU/dy∣\ell_m |dU/dy| and the length scale ℓm\ell_m.
  • 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 k3/2/εk^{3/2}/\varepsilon instead of prescribing it, and in a log layer in equilibrium it reduces to a mixing length κy\kappa y. 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 ℓ=CsΔ\ell = C_s \Delta set by the grid size and ∣dU/dy∣|dU/dy| replaced by the magnitude of the resolved strain rate.

Known results in the model

Viscous sublayer (exact in the model). As y+→0y^+ \to 0, ℓ+→0\ell^+ \to 0 and g→τ+=1g \to \tau^+ = 1, so U+=y+U^+ = y^+ to first order.

Log law (prediction of the model). For y+≫1y^+ \gg 1 with τ+=1\tau^+ = 1 and ℓ+=κy+\ell^+ = \kappa y^+, the viscous term is small and (κy+g)2=1(\kappa y^+ g)^2 = 1, so

U+=1κln⁡y++B.U^+ = \frac{1}{\kappa}\ln y^+ + B.

The slope 1/κ1/\kappa comes out of the model. The constant BB 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 ℓ+=κy+\ell^+ = \kappa y^+ and τ+=1\tau^+ = 1 the integral can be done:

U+(y+)=1κasinh⁡(2κy+)−1+4κ2y+2−12κ2y+.U^+(y^+) = \frac{1}{\kappa}\operatorname{asinh}(2\kappa y^+) - \frac{\sqrt{1 + 4\kappa^2 y^{+2}} - 1}{2\kappa^2 y^+}.

For large y+y^+ it gives B=(ln⁡(4κ)−1)/κ=−1.232B = (\ln(4\kappa) - 1)/\kappa = -1.232 at κ=0.41\kappa = 0.41. Values to check with a calculator: U+(1)=0.953U^+(1) = 0.953, U+(10)=4.672U^+(10) = 4.672, U+(100)=10.029U^+(100) = 10.029, U+(1000)=15.619U^+(1000) = 15.619. For example at y+=10y^+ = 10, 2κy+=8.22\kappa y^+ = 8.2 and asinh⁡(8.2)=ln⁡(8.2+68.24)=2.801\operatorname{asinh}(8.2) = \ln(8.2 + \sqrt{68.24}) = 2.801, so the first term is 2.801/0.41=6.8322.801/0.41 = 6.832; the second is (68.24−1)/3.362=2.160(\sqrt{68.24} - 1)/3.362 = 2.160; and U+=4.672U^+ = 4.672.

Van Driest damping (computed, checked by the tests). With A+=26A^+ = 26 and κ=0.41\kappa = 0.41, numerical integration gives U+(5)=4.88U^+(5) = 4.88, U+(10)=8.42U^+(10) = 8.42, U+(30)=13.19U^+(30) = 13.19, and U+−ln⁡(y+)/κ=5.30U^+ - \ln(y^+)/\kappa = 5.30, 5.295.29 and 5.285.28 at y+=100y^+ = 100, 300300 and 10001000. So the damped model has B≈5.28B \approx 5.28. Measured values of BB are about 5.0 to 5.2, and the value 26 of A+A^+ 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 dU/dy=50dU/dy = 50 1/s, the undamped model gives ℓm=0.41×0.01=0.0041\ell_m = 0.41 \times 0.01 = 0.0041 m and νt=0.00412×50=8.4×10−4\nu_t = 0.0041^2 \times 50 = 8.4 \times 10^{-4} m^2/s, about 56 times the molecular value 1.5×10−51.5 \times 10^{-5} m^2/s.

Channel flow (computed). With τ+=1−y+/Reτ\tau^+ = 1 - y^+/Re_\tau at Reτ=180Re_\tau = 180, the profile lies below the constant-stress one, and νt=0\nu_t = 0 at the centerline because dU/dy=0dU/dy = 0 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 νt\nu_t 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.

mixing_length_model.pyI0RawGitHub
# 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

  1. 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
  2. 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
  3. 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)
  4. 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.

LadderLevelWhat the next level needs
Human proofH0 no proof
  • add a proof in proofs/ (06.5)
LeanL0 no Lean part
  • name a Lean module in the lean field (07)
Code (python)I0 not checked yet
  • the tests did not run in this build
VisualV0 none
  • add viz/scene.ts or a figure (10)
WritingW4 complete
  • a review of the text: no review record reviews/QA49H0/text.yaml