Skip to content

Commit 284e90b

Browse files
authored
sync the gresho problem up with Castro (#218)
this is in line with the version from Miczek, Ropke, and Edelmann The default p0 sets a Mach number of ~ 0.13
1 parent ec50bf1 commit 284e90b

3 files changed

Lines changed: 45 additions & 49 deletions

File tree

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
[gresho]
2-
dens_base = 10.0 ; density at the base of the atmosphere
3-
scale_height = 2.0 ; scale height of the isothermal atmosphere
2+
rho0 = 1.0 ; density in the domain
3+
r = 0.2 ; radial location of peak velocity
44

5-
r = 1.0
6-
u0 = 1.0
7-
p0 = 1.0
8-
9-
dens_cutoff = 0.01
5+
p0 = 59.5 ; ambient pressure in the domain
6+
t_r = 1.0 ; reference time (used for setting peak velocity)

pyro/compressible/problems/gresho.py

Lines changed: 34 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import sys
22

3-
import numpy
3+
import numpy as np
44

55
from pyro.mesh import patch
66
from pyro.util import msg
@@ -13,7 +13,7 @@ def init_data(my_data, rp):
1313

1414
# make sure that we are passed a valid patch object
1515
if not isinstance(my_data, patch.CellCenterData2d):
16-
print("ErrrrOrr: patch invalid in bubble.py")
16+
print("Error: patch invalid in gresho.py")
1717
print(my_data.__class__)
1818
sys.exit()
1919

@@ -23,57 +23,55 @@ def init_data(my_data, rp):
2323
ymom = my_data.get_var("y-momentum")
2424
ener = my_data.get_var("energy")
2525

26-
# grav = rp.get_param("compressible.grav")
26+
myg = my_data.grid
27+
28+
x_center = 0.5 * (myg.x[0] + myg.x[-1])
29+
y_center = 0.5 * (myg.y[0] + myg.y[-1])
30+
L_x = myg.xmax - myg.xmin
2731

2832
gamma = rp.get_param("eos.gamma")
2933

30-
# scale_height = rp.get_param("gresho.scale_height")
31-
dens_base = rp.get_param("gresho.dens_base")
32-
dens_cutoff = rp.get_param("gresho.dens_cutoff")
34+
rho0 = rp.get_param("gresho.rho0")
35+
p0 = rp.get_param("gresho.p0")
3336

3437
rr = rp.get_param("gresho.r")
35-
u0 = rp.get_param("gresho.u0")
36-
p0 = rp.get_param("gresho.p0")
38+
t_r = rp.get_param("gresho.t_r")
3739

38-
# initialize the components -- we'll get a psure too
39-
# but that is used only to initialize the base state
40-
xmom[:, :] = 0.0
41-
ymom[:, :] = 0.0
42-
dens[:, :] = dens_cutoff
40+
q_r = 0.4 * np.pi * L_x / t_r
4341

44-
# set the density to be stratified in the y-direction
45-
myg = my_data.grid
4642
pres = myg.scratch_array()
43+
u_phi = myg.scratch_array()
4744

48-
dens[:, :] = dens_base
49-
45+
dens[:, :] = rho0
5046
pres[:, :] = p0
5147

52-
x_centre = 0.5 * (myg.x[0] + myg.x[-1])
53-
y_centre = 0.5 * (myg.y[0] + myg.y[-1])
48+
rad = np.sqrt((myg.x2d - x_center)**2 +
49+
(myg.y2d - y_center)**2)
5450

55-
rad = numpy.sqrt((myg.x2d - x_centre)**2 + (myg.y2d - y_centre)**2)
51+
indx1 = rad < rr
52+
u_phi[indx1] = 5.0 * rad[indx1]
53+
pres[indx1] = p0 + 12.5 * rad[indx1]**2
5654

57-
pres[rad <= rr] += 0.5 * (u0 * rad[rad <= rr]/rr)**2
58-
pres[(rad > rr) & (rad <= 2*rr)] += \
59-
u0**2 * (0.5 * (rad[(rad > rr) & (rad <= 2*rr)] / rr)**2 +
60-
4 * (1 - rad[(rad > rr) & (rad <= 2*rr)]/rr +
61-
numpy.log(rad[(rad > rr) & (rad <= 2*rr)]/rr)))
62-
pres[rad > 2*rr] += u0**2 * (4 * numpy.log(2) - 2)
63-
#
64-
uphi = numpy.zeros_like(pres)
65-
uphi[rad <= rr] = u0 * rad[rad <= rr]/rr
66-
uphi[(rad > rr) & (rad <= 2*rr)] = u0 * (2 - rad[(rad > rr) & (rad <= 2*rr)]/rr)
55+
indx2 = np.logical_and(rad >= rr, rad < 2.0*rr)
56+
u_phi[indx2] = 2.0 - 5.0 * rad[indx2]
57+
pres[indx2] = p0 + 12.5 * rad[indx2]**2 + \
58+
4.0 * (1.0 - 5.0 * rad[indx2] - np.log(rr) + np.log(rad[indx2]))
6759

68-
xmom[:, :] = -dens[:, :] * uphi[:, :] * (myg.y2d - y_centre) / rad[:, :]
69-
ymom[:, :] = dens[:, :] * uphi[:, :] * (myg.x2d - x_centre) / rad[:, :]
60+
indx3 = rad >= 2.0 * rr
61+
u_phi[indx3] = 0.0
62+
pres[indx3] = p0 + 12.5 * (2.0 * rr)**2 + \
63+
4.0 * (1.0 - 5.0 * (2.0 * rr) - np.log(rr) + np.log(2.0 * rr))
7064

71-
ener[:, :] = pres[:, :]/(gamma - 1.0) + \
72-
0.5*(xmom[:, :]**2 + ymom[:, :]**2)/dens[:, :]
65+
xmom[:, :] = -dens[:, :] * q_r * u_phi[:, :] * (myg.y2d - y_center) / rad[:, :]
66+
ymom[:, :] = dens[:, :] * q_r * u_phi[:, :] * (myg.x2d - x_center) / rad[:, :]
7367

74-
eint = pres[:, :]/(gamma - 1.0)
68+
ener[:, :] = pres[:, :] / (gamma - 1.0) + \
69+
0.5 * (xmom[:, :]**2 + ymom[:, :]**2) / dens[:, :]
7570

76-
dens[:, :] = pres[:, :]/(eint[:, :]*(gamma - 1.0))
71+
# report peak Mach number
72+
cs = np.sqrt(gamma * pres / dens)
73+
M = np.abs(q_r * u_phi).max() / cs.max()
74+
print(f"peak Mach number = {M}")
7775

7876

7977
def finalize():

pyro/compressible/problems/inputs.gresho

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@
22

33
[driver]
44
max_steps = 2000
5-
tmax = 10000.0
5+
tmax = 1
66
cfl = 0.8
77

88

99
[io]
1010
basename = lm_gresho_128_
11-
n_out = 1
11+
dt_out = 0.2
1212

1313

1414
[mesh]
15-
nx = 128
16-
ny = 128
15+
nx = 40
16+
ny = 40
1717
xmax = 1.0
1818
ymax = 1.0
1919

@@ -26,8 +26,9 @@ yrboundary = periodic
2626

2727
[gresho]
2828
r = 0.2
29-
u0 = 0.1
30-
p0 = 1
29+
rho0 = 1.0
30+
p0 = 59.5
31+
t_r = 1.0
3132

3233
[compressible]
3334
grav = 0

0 commit comments

Comments
 (0)