Skip to content

Commit

Permalink
update the ambient BCs for compressible
Browse files Browse the repository at this point in the history
this now allows stuff to flow out but not in
also tweak the initial conditions for convection
  • Loading branch information
zingale committed Dec 15, 2024
1 parent 81873bc commit c402eae
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 10 deletions.
25 changes: 21 additions & 4 deletions pyro/compressible/BC.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@

def user(bc_name, bc_edge, variable, ccdata):
"""
A hydrostatic boundary. This integrates the equation of HSE into
Extra boundary condition types for compressible hydro. This includes
a hydrostatic boundary, a ramp, and ambient.
For HSE, this integrates the equation of HSE into
the ghost cells to get the pressure and density under the assumption
that the specific internal energy is constant.
Expand Down Expand Up @@ -152,6 +155,16 @@ def user(bc_name, bc_edge, variable, ccdata):

if bc_edge == "yrb":

# store the normal momentum -- skip this if we are filling
# the sources
dens_inside = None
mom_normal = None
normal_vel_inside = None
if "y-momentum" in ccdata.names:
mom_normal = ccdata.get_var("y-momentum")[:, myg.jhi]
dens_inside = ccdata.get_var("density")[:, myg.jhi]
normal_vel_inside = mom_normal / dens_inside

# upper y boundary

# by default, use a zero gradient
Expand All @@ -169,13 +182,17 @@ def user(bc_name, bc_edge, variable, ccdata):

elif variable == "y-momentum":
rhov = ambient_rho * ambient_v
v[:, myg.jhi+1:myg.jhi+myg.ng+1] = rhov
# allow stuff to flow out, otherwise, reflect velocity
for j in range(myg.jhi+1, myg.jhi+myg.ng+1):
v[:, j] = np.where(mom_normal > 0, mom_normal, rhov)

elif variable == "energy":
gamma = ccdata.get_aux("gamma")
ke = 0.5 * ambient_rho * (ambient_u**2 + ambient_v**2)
yvel = np.where(mom_normal > 0, mom_normal/dens_inside, ambient_v)
ke = 0.5 * ambient_rho * (ambient_u**2 + yvel**2)
rhoE = ambient_p / (gamma - 1.0) + ke
v[:, myg.jhi+1:myg.jhi+myg.ng+1] = rhoE
for j in range(myg.jhi+1, myg.jhi+myg.ng+1):
v[:, j] = rhoE[:]

else:
msg.fail("error: ambient BC not supported for xlb, xrb, or ylb")
Expand Down
13 changes: 7 additions & 6 deletions pyro/compressible/problems/inputs.convection
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,18 @@ tmax = 10.0

[io]
basename = convection_
n_out = 100
n_out = 100000
dt_out = 0.25


[mesh]
nx = 128
ny = 384
ny = 512
xmax = 4.0
ymax = 12.0
ymax = 16.0

xlboundary = outflow
xrboundary = outflow
xlboundary = periodic
xrboundary = periodic

ylboundary = reflect
yrboundary = ambient
Expand All @@ -26,7 +27,7 @@ yrboundary = ambient
[convection]
scale_height = 2.0
dens_base = 1000.0
dens_cutoff = 1.e-3
dens_cutoff = 1.e-4

e_rate = 0.5

Expand Down

0 comments on commit c402eae

Please sign in to comment.