Skip to content

Commit 7a1562f

Browse files
authored
add spherical geometry support in compressible (#204)
this extends the unsplit / CTU compressible solver to work in a 2D spherical geometry (r, theta) modeled with phi axisymmetry.
1 parent 1cdab61 commit 7a1562f

16 files changed

Lines changed: 591 additions & 180 deletions

pyro/compressible/BC.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ def user(bc_name, bc_edge, variable, ccdata):
5353

5454
# we will take the density to be constant, the velocity to
5555
# be outflow, and the pressure to be in HSE
56-
if variable in ["density", "x-momentum", "y-momentum", "ymom_src", "E_src", "fuel", "ash"]:
56+
if variable in ["density", "x-momentum", "y-momentum",
57+
"dens_src", "xmom_src", "ymom_src", "E_src",
58+
"fuel", "ash"]:
5759
v = ccdata.get_var(variable)
5860
j = myg.jlo-1
5961
while j >= 0:
@@ -99,7 +101,9 @@ def user(bc_name, bc_edge, variable, ccdata):
99101

100102
# we will take the density to be constant, the velocity to
101103
# be outflow, and the pressure to be in HSE
102-
if variable in ["density", "x-momentum", "y-momentum", "ymom_src", "E_src", "fuel", "ash"]:
104+
if variable in ["density", "x-momentum", "y-momentum",
105+
"dens_src", "xmom_src", "ymom_src", "E_src",
106+
"fuel", "ash"]:
103107
v = ccdata.get_var(variable)
104108
for j in range(myg.jhi+1, myg.jhi+myg.ng+1):
105109
v[:, j] = v[:, myg.jhi]

pyro/compressible/interface.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def states(idir, ng, dx, dt,
6767
Are we predicting to the edges in the x-direction (1) or y-direction (2)?
6868
ng : int
6969
The number of ghost cells
70-
dx : float
70+
dx : ndarray
7171
The cell spacing
7272
dt : float
7373
The timestep
@@ -133,13 +133,13 @@ def states(idir, ng, dx, dt,
133133
q[irho] / cs, 0.0, 0.5 / (cs * cs)]
134134
lvec[1, :ns] = [1.0, 0.0,
135135
0.0, -1.0 / (cs * cs)]
136-
lvec[2, :ns] = [0.0, 0.0, 1.0, 0.0]
136+
lvec[2, :ns] = [0.0, 0.0, 1.0, 0.0]
137137
lvec[3, :ns] = [0.0, 0.5 *
138138
q[irho] / cs, 0.0, 0.5 / (cs * cs)]
139139

140140
rvec[0, :ns] = [1.0, -cs / q[irho], 0.0, cs * cs]
141-
rvec[1, :ns] = [1.0, 0.0, 0.0, 0.0]
142-
rvec[2, :ns] = [0.0, 0.0, 1.0, 0.0]
141+
rvec[1, :ns] = [1.0, 0.0, 0.0, 0.0]
142+
rvec[2, :ns] = [0.0, 0.0, 1.0, 0.0]
143143
rvec[3, :ns] = [1.0, cs / q[irho], 0.0, cs * cs]
144144

145145
# now the species -- they only have a 1 in their corresponding slot
@@ -174,29 +174,30 @@ def states(idir, ng, dx, dt,
174174
if idir == 1:
175175
# this is one the right face of the current zone,
176176
# so the fastest moving eigenvalue is e_val[3] = u + c
177-
factor = 0.5 * (1.0 - dtdx * max(e_val[3], 0.0))
177+
factor = 0.5 * (1.0 - dtdx[i, j] * max(e_val[3], 0.0))
178178
q_l[i + 1, j, :] = q + factor * dq
179179

180180
# left face of the current zone, so the fastest moving
181181
# eigenvalue is e_val[3] = u - c
182-
factor = 0.5 * (1.0 + dtdx * min(e_val[0], 0.0))
182+
factor = 0.5 * (1.0 + dtdx[i, j] * min(e_val[0], 0.0))
183183
q_r[i, j, :] = q - factor * dq
184184

185185
else:
186186

187-
factor = 0.5 * (1.0 - dtdx * max(e_val[3], 0.0))
187+
factor = 0.5 * (1.0 - dtdx[i, j] * max(e_val[3], 0.0))
188188
q_l[i, j + 1, :] = q + factor * dq
189189

190-
factor = 0.5 * (1.0 + dtdx * min(e_val[0], 0.0))
190+
factor = 0.5 * (1.0 + dtdx[i, j] * min(e_val[0], 0.0))
191191
q_r[i, j, :] = q - factor * dq
192192

193193
# compute the Vhat functions
194194
for m in range(nvar):
195195
asum = np.dot(lvec[m, :], dq)
196196

197-
betal[m] = dtdx4 * (e_val[3] - e_val[m]) * \
197+
# Should we change to max(e_val[3], 0.0) and min(e_val[0], 0.0)?
198+
betal[m] = dtdx4[i, j] * (e_val[3] - e_val[m]) * \
198199
(np.copysign(1.0, e_val[m]) + 1.0) * asum
199-
betar[m] = dtdx4 * (e_val[0] - e_val[m]) * \
200+
betar[m] = dtdx4[i, j] * (e_val[0] - e_val[m]) * \
200201
(1.0 - np.copysign(1.0, e_val[m])) * asum
201202

202203
# construct the states

pyro/compressible/problems/advect.py

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,38 @@ def init_data(my_data, rp):
3838
ymin = rp.get_param("mesh.ymin")
3939
ymax = rp.get_param("mesh.ymax")
4040

41-
xctr = 0.5*(xmin + xmax)
42-
yctr = 0.5*(ymin + ymax)
41+
myg = my_data.grid
4342

44-
# this is identical to the advection/smooth problem
45-
dens[:, :] = 1.0 + np.exp(-60.0*((my_data.grid.x2d-xctr)**2 +
46-
(my_data.grid.y2d-yctr)**2))
43+
if myg.coord_type == 0:
44+
xctr = 0.5*(xmin + xmax)
45+
yctr = 0.5*(ymin + ymax)
46+
47+
# this is identical to the advection/smooth problem
48+
dens[:, :] = 1.0 + np.exp(-60.0*((my_data.grid.x2d-xctr)**2 +
49+
(my_data.grid.y2d-yctr)**2))
50+
51+
# velocity is diagonal
52+
u = 1.0
53+
v = 1.0
54+
55+
else:
56+
x = myg.scratch_array()
57+
y = myg.scratch_array()
58+
59+
xctr = 0.5*(xmin + xmax) * np.sin((ymin + ymax) * 0.25)
60+
yctr = 0.5*(xmin + xmax) * np.cos((ymin + ymax) * 0.25)
61+
62+
x[:, :] = myg.x2d.v(buf=myg.ng) * np.sin(myg.y2d.v(buf=myg.ng))
63+
y[:, :] = myg.x2d.v(buf=myg.ng) * np.cos(myg.y2d.v(buf=myg.ng))
64+
65+
# this is identical to the advection/smooth problem
66+
dens[:, :] = 1.0 + np.exp(-120.0*((x-xctr)**2 +
67+
(y-yctr)**2))
68+
69+
# velocity in theta direction.
70+
u = 0.0
71+
v = 1.0
4772

48-
# velocity is diagonal
49-
u = 1.0
50-
v = 1.0
5173
xmom[:, :] = dens[:, :]*u
5274
ymom[:, :] = dens[:, :]*v
5375

pyro/compressible/problems/inputs.advect.128

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ cvisc = 0.1
1212

1313

1414
[io]
15-
basename = advect_
15+
basename = advect_128_
1616

1717

1818
[eos]

pyro/compressible/problems/inputs.advect.256

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ cvisc = 0.1
1212

1313

1414
[io]
15-
basename = advect_
15+
basename = advect_256_
1616

1717

1818
[eos]

pyro/compressible/problems/inputs.advect.64

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ cvisc = 0.1
1212

1313

1414
[io]
15-
basename = advect_
15+
basename = advect_64_
1616

1717

1818
[eos]
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
[driver]
2+
max_steps = 500
3+
tmax = 1.0
4+
5+
init_tstep_factor = 1.0
6+
fix_dt = 0.0025
7+
8+
9+
[compressible]
10+
limiter = 0
11+
cvisc = 0.1
12+
riemann = CGF
13+
14+
[io]
15+
basename = spherical_advect_128_
16+
17+
18+
[eos]
19+
gamma = 1.4
20+
21+
22+
[mesh]
23+
grid_type = SphericalPolar
24+
nx = 128
25+
ny = 128
26+
xmin = 1.0
27+
xmax = 2.0
28+
ymin = 0.523
29+
ymax = 2.617
30+
31+
xlboundary = outflow
32+
xrboundary = outflow
33+
34+
ylboundary = outflow
35+
yrboundary = outflow
36+
37+
38+
[vis]
39+
dovis = 1
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
[driver]
2+
max_steps = 1000
3+
tmax = 1.0
4+
5+
init_tstep_factor = 1.0
6+
fix_dt = 0.00125
7+
8+
9+
[compressible]
10+
limiter = 0
11+
cvisc = 0.1
12+
riemann = CGF
13+
14+
[io]
15+
basename = spherical_advect_256_
16+
17+
18+
[eos]
19+
gamma = 1.4
20+
21+
22+
[mesh]
23+
grid_type = SphericalPolar
24+
nx = 256
25+
ny = 256
26+
xmin = 1.0
27+
xmax = 2.0
28+
ymin = 0.523
29+
ymax = 2.617
30+
31+
xlboundary = outflow
32+
xrboundary = outflow
33+
34+
ylboundary = outflow
35+
yrboundary = outflow
36+
37+
38+
[vis]
39+
dovis = 1
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
[driver]
2+
max_steps = 500
3+
tmax = 1.0
4+
5+
init_tstep_factor = 1.0
6+
fix_dt = 0.005
7+
8+
9+
[compressible]
10+
limiter = 0
11+
cvisc = 0.1
12+
riemann = CGF
13+
14+
[io]
15+
basename = spherical_advect_64_
16+
17+
18+
[eos]
19+
gamma = 1.4
20+
21+
22+
[mesh]
23+
grid_type = SphericalPolar
24+
nx = 64
25+
ny = 64
26+
xmin = 1.0
27+
xmax = 2.0
28+
ymin = 0.523
29+
ymax = 2.617
30+
31+
xlboundary = outflow
32+
xrboundary = outflow
33+
34+
ylboundary = outflow
35+
yrboundary = outflow
36+
37+
38+
[vis]
39+
dovis = 1
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
[driver]
2+
max_steps = 5000
3+
tmax = 0.1
4+
5+
6+
[compressible]
7+
limiter = 2
8+
cvisc = 0.1
9+
riemann = CGF
10+
11+
[io]
12+
basename = sedov_spherical_
13+
dt_out = 0.0125
14+
15+
16+
[eos]
17+
gamma = 1.4
18+
19+
20+
[mesh]
21+
grid_type = SphericalPolar
22+
nx = 128
23+
ny = 128
24+
xmin = 0.1
25+
xmax = 1.0
26+
ymin = 0.785
27+
ymax = 2.355
28+
29+
xlboundary = reflect-odd
30+
xrboundary = outflow
31+
32+
ylboundary = outflow
33+
yrboundary = outflow
34+
35+
36+
[sedov]
37+
r_init = 0.13
38+
39+
40+
[vis]
41+
dovis = 1

0 commit comments

Comments
 (0)