Skip to content

Commit 6a70234

Browse files
committed
new RT with 2 modes
1 parent 49e2703 commit 6a70234

4 files changed

Lines changed: 134 additions & 1 deletion

File tree

compressible/problems/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__all__ = ['acoustic_pulse', 'advect', 'bubble', 'hse', 'kh', 'logo', 'quad', 'rt', 'sedov', 'sod', 'test']
1+
__all__ = ['acoustic_pulse', 'advect', 'bubble', 'hse', 'kh', 'logo', 'quad', 'rt', 'rt2', 'sedov', 'sod', 'test']
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[rt2]
2+
dens1 = 1.0
3+
dens2 = 2.0
4+
5+
amp = 1.0
6+
sigma = 0.1
7+
8+
p0 = 10.0
9+
10+

compressible/problems/inputs.rt2

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 = 5.0
6+
7+
8+
[io]
9+
basename = rt_
10+
n_out = 10000
11+
dt_out = 0.025
12+
13+
[mesh]
14+
nx = 384
15+
ny = 192
16+
xmax = 6.0
17+
ymax = 3.0
18+
19+
xlboundary = periodic
20+
xrboundary = periodic
21+
22+
ylboundary = hse
23+
yrboundary = hse
24+
25+
26+
[rt2]
27+
amp = 0.1
28+
sigma = 0.025
29+
30+
[compressible]
31+
grav = -1.0
32+
33+
limiter = 2

compressible/problems/rt2.py

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
"""A RT problem with two distinct modes: short wave length on the
2+
left and long wavelenght on the right. This allows one to see
3+
how the growth rate depends on wavenumber.
4+
"""
5+
6+
from __future__ import print_function
7+
8+
import numpy as np
9+
10+
import sys
11+
import mesh.patch as patch
12+
from util import msg
13+
14+
15+
def init_data(my_data, rp):
16+
17+
""" initialize the rt problem """
18+
19+
msg.bold("initializing the rt problem...")
20+
21+
# make sure that we are passed a valid patch object
22+
if not isinstance(my_data, patch.CellCenterData2d):
23+
print("ERROR: patch invalid in rt2.py")
24+
print(my_data.__class__)
25+
sys.exit()
26+
27+
# get the density, momenta, and energy as separate variables
28+
dens = my_data.get_var("density")
29+
xmom = my_data.get_var("x-momentum")
30+
ymom = my_data.get_var("y-momentum")
31+
ener = my_data.get_var("energy")
32+
33+
gamma = rp.get_param("eos.gamma")
34+
35+
grav = rp.get_param("compressible.grav")
36+
37+
dens1 = rp.get_param("rt2.dens1")
38+
dens2 = rp.get_param("rt2.dens2")
39+
p0 = rp.get_param("rt2.p0")
40+
amp = rp.get_param("rt2.amp")
41+
sigma = rp.get_param("rt2.sigma")
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+
f_l = 18
51+
f_r = 3
52+
53+
# set the density to be stratified in the y-direction
54+
myg = my_data.grid
55+
56+
xcenter = 0.5*(myg.xmin + myg.xmax)
57+
ycenter = 0.5*(myg.ymin + myg.ymax)
58+
59+
p = myg.scratch_array()
60+
61+
j = myg.jlo
62+
while j <= myg.jhi:
63+
if (myg.y[j] < ycenter):
64+
dens[:, j] = dens1
65+
p[:, j] = p0 + dens1*grav*myg.y[j]
66+
67+
else:
68+
dens[:, j] = dens2
69+
p[:, j] = p0 + dens1*grav*ycenter + dens2*grav*(myg.y[j] - ycenter)
70+
71+
j += 1
72+
73+
idx_l = myg.x2d < (myg.xmax - myg.xmin)/3.0
74+
idx_r = myg.x2d >= (myg.xmax - myg.xmin)/3.0
75+
76+
ymom[idx_l] = amp*np.sin(4.0*np.pi*f_l*myg.x2d[idx_l]/(myg.xmax-myg.xmin))*np.exp(-(myg.y2d[idx_l]-ycenter)**2/sigma**2)
77+
ymom[idx_r] = amp*np.sin(4.0*np.pi*f_r*myg.x2d[idx_r]/(myg.xmax-myg.xmin))*np.exp(-(myg.y2d[idx_r]-ycenter)**2/sigma**2)
78+
79+
print(ymom[:,100])
80+
81+
ymom *= dens
82+
83+
# set the energy (P = cs2*dens)
84+
ener[:, :] = p[:, :]/(gamma - 1.0) + \
85+
0.5*(xmom[:, :]**2 + ymom[:, :]**2)/dens[:, :]
86+
87+
88+
def finalize():
89+
""" print out any information to the user at the end of the run """
90+
pass

0 commit comments

Comments
 (0)