Skip to content

Commit f73c3e0

Browse files
authored
add a multimode RT problem (#307)
This seems to work with both compressible and compressible_fv4.
1 parent 81873bc commit f73c3e0

File tree

2 files changed

+118
-0
lines changed

2 files changed

+118
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# simple inputs files for the four-corner problem.
2+
3+
[driver]
4+
max_steps = 10000
5+
tmax = 3.0
6+
7+
8+
[io]
9+
basename = rt_
10+
n_out = 100
11+
12+
13+
[mesh]
14+
nx = 64
15+
ny = 192
16+
xmax = 1.0
17+
ymax = 3.0
18+
19+
xlboundary = periodic
20+
xrboundary = periodic
21+
22+
ylboundary = hse
23+
yrboundary = hse
24+
25+
26+
[rt_multimode]
27+
amp = 0.25
28+
nmodes = 12
29+
30+
[compressible]
31+
grav = -1.0
32+
33+
limiter = 2
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
"""A multi-mode Rayleigh-Taylor instability."""
2+
3+
import numpy as np
4+
5+
from pyro.util import msg
6+
7+
DEFAULT_INPUTS = "inputs.rt_multimode"
8+
9+
PROBLEM_PARAMS = {"rt_multimode.dens1": 1.0,
10+
"rt_multimode.dens2": 2.0,
11+
"rt_multimode.amp": 1.0,
12+
"rt_multimode.sigma": 0.1,
13+
"rt_multimode.nmodes": 10,
14+
"rt_multimode.p0": 10.0}
15+
16+
17+
def init_data(my_data, rp):
18+
""" initialize the rt problem """
19+
20+
# see the random number generator
21+
rng = np.random.default_rng(12345)
22+
23+
if rp.get_param("driver.verbose"):
24+
msg.bold("initializing the rt problem...")
25+
26+
# get the density, momenta, and energy as separate variables
27+
dens = my_data.get_var("density")
28+
xmom = my_data.get_var("x-momentum")
29+
ymom = my_data.get_var("y-momentum")
30+
ener = my_data.get_var("energy")
31+
32+
gamma = rp.get_param("eos.gamma")
33+
34+
grav = rp.get_param("compressible.grav")
35+
36+
dens1 = rp.get_param("rt_multimode.dens1")
37+
dens2 = rp.get_param("rt_multimode.dens2")
38+
p0 = rp.get_param("rt_multimode.p0")
39+
amp = rp.get_param("rt_multimode.amp")
40+
sigma = rp.get_param("rt_multimode.sigma")
41+
nmodes = rp.get_param("rt_multimode.nmodes")
42+
43+
# initialize the components, remember, that ener here is
44+
# rho*eint + 0.5*rho*v**2, where eint is the specific
45+
# internal energy (erg/g)
46+
xmom[:, :] = 0.0
47+
ymom[:, :] = 0.0
48+
dens[:, :] = 0.0
49+
50+
# set the density to be stratified in the y-direction
51+
myg = my_data.grid
52+
53+
ycenter = 0.5*(myg.ymin + myg.ymax)
54+
55+
p = myg.scratch_array()
56+
57+
j = myg.jlo
58+
while j <= myg.jhi:
59+
if myg.y[j] < ycenter:
60+
dens[:, j] = dens1
61+
p[:, j] = p0 + dens1*grav*myg.y[j]
62+
63+
else:
64+
dens[:, j] = dens2
65+
p[:, j] = p0 + dens1*grav*ycenter + dens2*grav*(myg.y[j] - ycenter)
66+
67+
j += 1
68+
69+
# add multiple modes to the vertical velocity
70+
L = myg.xmax - myg.xmin
71+
for k in range(1, nmodes+1):
72+
phase = rng.random() * 2 * np.pi
73+
mode_amp = amp * rng.random()
74+
ymom[:, :] += (mode_amp * np.cos(2.0 * np.pi * k*myg.x2d / L + phase) *
75+
np.exp(-(myg.y2d - ycenter)**2 / sigma**2))
76+
ymom /= nmodes
77+
ymom *= dens
78+
79+
# set the energy (P = cs2*dens)
80+
ener[:, :] = p[:, :]/(gamma - 1.0) + \
81+
0.5*(xmom[:, :]**2 + ymom[:, :]**2)/dens[:, :]
82+
83+
84+
def finalize():
85+
""" print out any information to the user at the end of the run """

0 commit comments

Comments
 (0)