Wavemaker and base-flow sensitivity of Orszag’s Tollmien-Schlichting mode (plane Poiseuille, Re = 1e4, alpha = 1), then the steady-forcing sensitivity

Family: shear · Script: examples/shear/sensitivity_wavemaker.py

Obtained

wavemaker maximum S = 11.4856 at y = ±0.87387 (critical layer U = c_r); derivative of the pencil = Richardson finite difference to 5e-11; density (continuous adjoint) → pencil to 2e-12 (N = 80)

Reference

no exact published value in a channel; closed forms of Chomaz (2005) for Ginzburg–Landau (tests/sensitivity)

Run: python examples/shear/sensitivity_wavemaker.py   (about 10 s of CPU; figure in $CN_OUT or .)

Run it: python examples/shear/sensitivity_wavemaker.py (in the conatus environment).

 1"""Wavemaker and base-flow sensitivity of Orszag's Tollmien-Schlichting mode (plane Poiseuille,
 2Re = 1e4, alpha = 1), then the steady-forcing sensitivity.
 3
 4Run: python examples/shear/sensitivity_wavemaker.py   (about 10 s of CPU; figure in $CN_OUT or .)
 5"""
 6import os
 7
 8import numpy as np
 9
10from conatus.expert import Y, base_flow_sensitivity, parallel_shear_flow, structural_sensitivity
11from conatus.sensitivity import steady_forcing_sensitivity
12
13RE = 1e4
14
15
16def lns(U):
17    """Linearized Navier-Stokes around U(y) e_x (declared: kx, kz, Re, no-slip walls)."""
18    return parallel_shear_flow(U, kx=1.0, kz=0.0, Re=RE, walls="no-slip")
19
20
21adjoint_bcs = [(f, 0, s) for f in ("u", "v", "w") for s in ("left", "right")]
22bfs = base_flow_sensitivity(lns, 1 - Y ** 2, N=80, target=-1j * (0.2375265 + 0.0037397j),
23                            adjoint="continuous", infinite_tol=1e-10, adjoint_bcs=adjoint_bcs)
24print(bfs.explain())
25st = structural_sensitivity(bfs.pair)
26y_star, s_star = st.maximum(points=2001)
27print(f"wavemaker maximum S = {s_star:.6g} at y = {y_star:.6f} (critical layers of the TS mode)")
28fs = steady_forcing_sensitivity(bfs, operator={2: 1 / RE}, bcs=[(0, "left"), (0, "right")], N=80)
29print(fs.explain())
30print(f"uniform extra pressure gradient dF = 1: d sigma = {fs.predict(1):.6g}")
31
32try:
33    import matplotlib
34    matplotlib.use("Agg")
35    import matplotlib.pyplot as plt
36    y = np.linspace(-1, 1, 801)
37    fig, ax = plt.subplots(1, 3, figsize=(11, 3.2), sharey=True)
38    ax[0].plot(st.wavemaker(y), y)
39    ax[0].set_title("wavemaker S(y)")
40    G = bfs.gradient(y)
41    # sigma = -i omega (target -1j * c): Re sigma is the growth rate, Im sigma minus the frequency
42    ax[1].plot(G.real, y, label="Re (growth)")
43    ax[1].plot(G.imag, y, label="Im (frequency)")
44    ax[1].set_title(r"$\delta\sigma/\delta U$")
45    ax[1].legend()
46    H = fs.gradient(y)
47    ax[2].plot(H.real, y)
48    ax[2].plot(H.imag, y)
49    ax[2].set_title(r"$\delta\sigma/\delta F$")
50    ax[0].set_ylabel("y")
51    fig.tight_layout()
52    out = os.path.join(os.environ.get("CN_OUT", "."), "sensitivity_wavemaker.png")
53    fig.savefig(out, dpi=120)
54    print("figure:", out)
55except ImportError:
56    print("matplotlib not available: no figure")