Skip to content

Commit 59e072d

Browse files
committed
implement a sponge term in compressible
1 parent 1289879 commit 59e072d

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

pyro/compressible/_defaults

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@ grav = 0.0 ; gravitational acceleration (in y-direction)
2121

2222
riemann = HLLC ; HLLC or CGF
2323

24+
[sponge]
25+
do_sponge = 0 ; do we include a sponge source term
26+
27+
sponge_rho_begin = 1.e-2 ; density below which to begin the sponge
28+
sponge_rho_full = 1.e-3 ; density below which the sponge is fully enabled
29+
sponge_timescale = 1.e-2 ; the timescale over which the sponge should act
30+
2431
[particles]
2532
do_particles = 0
2633
particle_generator = grid

pyro/compressible/simulation.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,29 @@ def get_external_sources(t, dt, U, ivars, rp, myg, *, U_old=None, problem_source
156156
return S
157157

158158

159+
def get_sponge_factor(U, ivars, rp, myg):
160+
"""compute the sponge factor, f / tau, that goes into a
161+
sponge damping term of the form S = - (f / tau) (rho U)"""
162+
163+
rho = U[:, :, ivars.idens]
164+
rho_begin = rp.get_param("sponge.sponge_rho_begin")
165+
rho_full = rp.get_param("sponge.sponge_rho_full")
166+
167+
assert rho_begin > rho_full
168+
169+
f = myg.scratch_array()
170+
171+
f[:, :] = np.where(rho > rho_begin,
172+
0.0,
173+
np.where(rho < rho_full,
174+
1.0,
175+
0.5 * (1.0 - np.cos(np.pi * (rho - rho_begin) /
176+
(rho_full - rho_begin)))))
177+
178+
tau = rp.get_param("sponge.sponge_timescale")
179+
return f / tau
180+
181+
159182
class Simulation(NullSimulation):
160183
"""The main simulation class for the corner transport upwind
161184
compressible hydrodynamics solver
@@ -392,6 +415,14 @@ def evolve(self):
392415
var = self.cc_data.get_var_by_index(n)
393416
var.v()[:, :] += 0.5 * self.dt * (S_new.v(n=n) - S_old.v(n=n))
394417

418+
# finally, do the sponge, if desired -- this is formulated as an
419+
# implicit update to the velocity
420+
if self.rp.get_param("sponge.do_sponge"):
421+
kappa_f = get_sponge_factor(self.cc_data.data, self.ivars, self.rp, myg)
422+
423+
self.cc_data.data[:, :, self.ivars.ixmom] /= (1.0 + self.dt * kappa_f)
424+
self.cc_data.data[:, :, self.ivars.iymom] /= (1.0 + self.dt * kappa_f)
425+
395426
if self.particles is not None:
396427
self.particles.update_particles(self.dt)
397428

0 commit comments

Comments
 (0)