Skip to content

Commit 4a3d5ac

Browse files
committed
merge and update lag case files to generate their own input file
1 parent 492f052 commit 4a3d5ac

10 files changed

Lines changed: 2165 additions & 7033 deletions

File tree

examples/2D_lagrange_in_crossflow/case.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env python3
22
import json
33
import math
4+
import os
45

56
# Bubble screen
67
# Description: A planar acoustic wave interacts with a bubble cloud
@@ -54,6 +55,27 @@
5455
Nx = 240 # number of elements into x direction
5556
Ny = 50 # number of elements into y direction
5657

58+
# Lagrangian bubble initial conditions
59+
# Columns: x, y, z, u, v, w, R, pad (all nondimensional; lengths in units of x0)
60+
lag_bubbles = [
61+
(-10.0, -2.0, 0.0, 0.0, 0.0, 0.0, 0.1000, 0.0),
62+
(-10.0, -1.0, 0.0, 0.0, 0.0, 0.0, 0.1500, 0.0),
63+
(-10.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.1500, 0.0),
64+
(-10.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.1500, 0.0),
65+
(-10.0, 2.0, 0.0, 0.0, 0.0, 0.0, 0.1009, 0.0),
66+
]
67+
68+
69+
def write_lag_bubbles_file():
70+
input_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), "input")
71+
os.makedirs(input_dir, exist_ok=True)
72+
with open(os.path.join(input_dir, "lag_bubbles.dat"), "w") as f:
73+
for row in lag_bubbles:
74+
f.write("".join(f"{v:15.6E}" for v in row) + "\n")
75+
76+
77+
write_lag_bubbles_file()
78+
5779
# Configuring case dictionary
5880
print(
5981
json.dumps(
@@ -117,7 +139,7 @@
117139
"thermal": 3,
118140
"polytropic": "F",
119141
"fd_order": 2,
120-
"lag_params%nBubs_glb": 5,
142+
"lag_params%nBubs_glb": len(lag_bubbles),
121143
"lag_params%vel_model": 2,
122144
"lag_params%drag_model": 3,
123145
"lag_params%solver_approach": 1,

examples/2D_lagrange_in_crossflow/input/lag_bubbles.dat

Lines changed: 0 additions & 5 deletions
This file was deleted.

examples/2D_lagrange_rising_bubble/case.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env python3
22
import json
33
import math
4+
import os
45

56
# Bubble screen
67
# Description: A planar acoustic wave interacts with a bubble cloud
@@ -53,6 +54,22 @@
5354
Nx = 50 # number of elements into x direction
5455
Ny = 50 # number of elements into y direction
5556

57+
# Lagrangian bubble seeding: 5 bubbles along y=-2 with varying radii
58+
lag_bubbles = [
59+
# x, y, z, u, v, w, R, interface velocity
60+
(-2.0, -2.0, 0.0, 0.0, 0.0, 0.0, 0.100, 0.0),
61+
(-1.0, -2.0, 0.0, 0.0, 0.0, 0.0, 0.125, 0.0),
62+
(0.0, -2.0, 0.0, 0.0, 0.0, 0.0, 0.150, 0.0),
63+
(1.0, -2.0, 0.0, 0.0, 0.0, 0.0, 0.125, 0.0),
64+
(2.0, -2.0, 0.0, 0.0, 0.0, 0.0, 0.075, 0.0),
65+
]
66+
67+
input_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), "input")
68+
os.makedirs(input_dir, exist_ok=True)
69+
with open(os.path.join(input_dir, "lag_bubbles.dat"), "w") as f:
70+
for row in lag_bubbles:
71+
f.write("\t".join(f"{v: .6E}" for v in row) + "\n")
72+
5673
# Configuring case dictionary
5774
print(
5875
json.dumps(

examples/2D_lagrange_rising_bubble/input/lag_bubbles.dat

Lines changed: 0 additions & 5 deletions
This file was deleted.

examples/2D_moving_lag_bubs/case.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import argparse
33
import json
44
import math
5+
import os
56

67
import numpy as np
78

@@ -199,4 +200,48 @@
199200

200201
mods = {}
201202

203+
204+
def write_lag_bubbles_file():
205+
nBubs = 2000
206+
r_inner = 0.25 / L0
207+
r_outer = 0.50 / L0
208+
R_min, R_max = 0.5, 1.0
209+
z_half = 5.0 # virtual z depth (must satisfy |z| < lag_params%charwidth/2)
210+
max_attempts = 10000
211+
212+
rng = np.random.default_rng(seed=42)
213+
x_pos = np.zeros(nBubs)
214+
y_pos = np.zeros(nBubs)
215+
z_pos = np.zeros(nBubs)
216+
R_bub = np.zeros(nBubs)
217+
218+
for n in range(nBubs):
219+
for _ in range(max_attempts):
220+
u = rng.uniform(0.0, 1.0)
221+
r = math.sqrt(r_inner**2 + u * (r_outer**2 - r_inner**2))
222+
theta = rng.uniform(0.0, 2.0 * math.pi)
223+
xi = r * math.cos(theta)
224+
yi = r * math.sin(theta)
225+
zi = rng.uniform(-z_half, z_half)
226+
Ri = rng.uniform(R_min, R_max)
227+
if n == 0:
228+
break
229+
dx = x_pos[:n] - xi
230+
dy = y_pos[:n] - yi
231+
dist = np.sqrt(dx * dx + dy * dy)
232+
if np.all(dist >= 2 * (R_bub[:n] + Ri)):
233+
break
234+
else:
235+
raise RuntimeError(f"Could not place bubble {n} without overlap after {max_attempts} attempts")
236+
x_pos[n], y_pos[n], z_pos[n], R_bub[n] = xi, yi, zi, Ri
237+
238+
input_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), "input")
239+
os.makedirs(input_dir, exist_ok=True)
240+
with open(os.path.join(input_dir, "lag_bubbles.dat"), "w") as f:
241+
for i in range(nBubs):
242+
f.write(f"{x_pos[i]:12.6f}\t{y_pos[i]:12.6f}\t{z_pos[i]:12.6f}\t{0.0:12.6f}\t{0.0:12.6f}\t{0.0:12.6f}\t{R_bub[i]:12.6f}\t{0.0:12.6f}\n")
243+
244+
245+
write_lag_bubbles_file()
246+
202247
print(json.dumps({**data, **mods}, indent=4))

0 commit comments

Comments
 (0)