Skip to content

Commit ba0cd0e

Browse files
bigfootedclaude
andauthored
Morse swirling jet: add the inlet profile script (#216)
* Morse swirling jet: add the inlet profile script morse_inlet.py writes inlet_jet.dat from the ERCOFTAC station 1 measurements (morse1.dat) and the inlet template written by SU2. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Morse swirling jet: inline the inlet script settings The command-line options are replaced by constants at the top of the script. The uniform nu_t option and the swirl sign are removed; the script writes the same inlet_jet.dat as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent b476a3a commit ba0cd0e

1 file changed

Lines changed: 65 additions & 0 deletions

File tree

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#!/usr/bin/env python3
2+
"""Inlet profile of the Morse swirling jet at x/D = 0.5 for the SU2 wedge mesh.
3+
4+
Fills the template that SU2 writes (example_inlet_jet.dat) with the measured axial, radial and swirl velocity of
5+
station 1 (morse1.dat: r/x, r/r05, U/Ucl, V/Ucl, W/Wmax, ...), converted to Cartesian components on the wedge
6+
face. The eddy viscosity follows from the measured shear stress, nu_t = -u'v' / (dU/dr), and nu_tilde from
7+
nu_t = nu_tilde f_v1.
8+
"""
9+
10+
import numpy as np
11+
12+
DATA = "morse1.dat"
13+
TEMPLATE = "example_inlet_jet.dat"
14+
OUTPUT = "inlet_jet.dat"
15+
DIAMETER = 0.0246 # m
16+
X_OVER_D = 0.5 # station of the profile
17+
U_CL = 34.10 # centreline velocity at the station, m/s
18+
W_MAX = 16.50 # maximum swirl velocity at the station, m/s
19+
NU = 1.82e-5 / 1.2 # kinematic viscosity, m^2/s
20+
STRAIN_FRACTION = 0.1 # u'v' is used where |dU/dr| exceeds this fraction of its maximum
21+
22+
23+
def nu_tilde_from_nu_t(nu_t):
24+
"""Invert nu_t = nu_tilde chi^3 / (chi^3 + 7.1^3) for nu_tilde by Newton iteration on chi."""
25+
target = nu_t / NU
26+
chi = np.maximum(target, 1.0)
27+
for _ in range(50):
28+
f = chi**4 / (chi**3 + 7.1**3) - target
29+
df = (chi**6 + 4 * 7.1**3 * chi**3) / (chi**3 + 7.1**3) ** 2
30+
chi = np.maximum(chi - f / df, 1e-6)
31+
return chi * NU
32+
33+
34+
data = np.loadtxt(DATA, comments="#")
35+
r_data = data[:, 0] * X_OVER_D * DIAMETER
36+
U_data, V_data, W_data = data[:, 2] * U_CL, data[:, 3] * U_CL, data[:, 4] * W_MAX
37+
uv_data = data[:, 8] * U_CL**2
38+
39+
with open(TEMPLATE) as f:
40+
lines = f.read().splitlines()
41+
is_row = [l[:1].isdigit() or l[:1] == "-" for l in lines]
42+
head = [l for l, row in zip(lines, is_row) if not row]
43+
rows = np.array([[float(v) for v in l.split()] for l, row in zip(lines, is_row) if row])
44+
r, th = np.hypot(rows[:, 1], rows[:, 2]), np.arctan2(rows[:, 2], rows[:, 1])
45+
46+
U = np.interp(r, r_data, U_data)
47+
V = np.interp(r, r_data, V_data)
48+
W = np.interp(r, r_data, W_data)
49+
vel = np.column_stack([U, V * np.cos(th) - W * np.sin(th), V * np.sin(th) + W * np.cos(th)])
50+
mag = np.linalg.norm(vel, axis=1)
51+
rows[:, 4] = mag
52+
rows[:, 5:8] = vel / mag[:, None]
53+
54+
# nu_t = -u'v' / (dU/dr) where the shear is large, dV/dx neglected; held at the nearest value elsewhere.
55+
dU_dr = np.gradient(U_data, r_data)
56+
sheared = np.abs(dU_dr) >= STRAIN_FRACTION * np.abs(dU_dr).max()
57+
nu_t = np.maximum(np.interp(r, r_data[sheared], -uv_data[sheared] / dU_dr[sheared]), NU)
58+
rows[:, 8] = nu_tilde_from_nu_t(nu_t)
59+
60+
with open(OUTPUT, "w") as f:
61+
f.write("\n".join(head) + "\n")
62+
for row in rows:
63+
f.write("\t".join(f"{v:.15e}" for v in row) + "\n")
64+
print(f"{OUTPUT}: {len(rows)} points, |U| in [{mag.min():.2f}, {mag.max():.2f}] m/s, "
65+
f"nu_t/nu in [{nu_t.min() / NU:.1f}, {nu_t.max() / NU:.1f}]")

0 commit comments

Comments
 (0)