Skip to content

Commit

Permalink
add a sponge to the compressible solvers
Browse files Browse the repository at this point in the history
for the CTU solver, the sponge update is implicit in time
for the RK/SDC solvers, it is an explicit source
this damps the velocity field over a timescale "sponge_timescale"
The sponge is essentially the same as in Castro
  • Loading branch information
zingale committed Jan 9, 2025
1 parent 59e072d commit 4a074a6
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pyro/compressible/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
__all__ = ["simulation"]

from .simulation import (Simulation, Variables, cons_to_prim,
get_external_sources, prim_to_cons)
get_external_sources, get_sponge_factor, prim_to_cons)
1 change: 1 addition & 0 deletions pyro/compressible/_defaults
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ grav = 0.0 ; gravitational acceleration (in y-direction)

riemann = HLLC ; HLLC or CGF


[sponge]
do_sponge = 0 ; do we include a sponge source term

Expand Down
8 changes: 8 additions & 0 deletions pyro/compressible_fv4/_defaults
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,12 @@ grav = 0.0 ; gravitational acceleration (in y-direction)
riemann = CGF


[sponge]
do_sponge = 0 ; do we include a sponge source term

sponge_rho_begin = 1.e-2 ; density below which to begin the sponge
sponge_rho_full = 1.e-3 ; density below which the sponge is fully enabled
sponge_timescale = 1.e-2 ; the timescale over which the sponge should act



9 changes: 8 additions & 1 deletion pyro/compressible_fv4/simulation.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pyro.compressible_fv4.fluxes as flx
from pyro import compressible_rk
from pyro.compressible import get_external_sources
from pyro.compressible import get_external_sources, get_sponge_factor
from pyro.mesh import fv, integration


Expand Down Expand Up @@ -48,6 +48,13 @@ def substep(self, myd):
(flux_x.v(n=n) - flux_x.ip(1, n=n))/myg.dx + \
(flux_y.v(n=n) - flux_y.jp(1, n=n))/myg.dy + S.v(n=n)

# finally, add the sponge source, if desired
if self.rp.get_param("sponge.do_sponge"):
kappa_f = get_sponge_factor(myd.data, self.ivars, self.rp, myg)

k.v(n=self.ivars.ixmom)[:, :] -= kappa_f.v() * myd.data.v(n=self.ivars.ixmom)
k.v(n=self.ivars.iymom)[:, :] -= kappa_f.v() * myd.data.v(n=self.ivars.iymom)

return k

def preevolve(self):
Expand Down
6 changes: 6 additions & 0 deletions pyro/compressible_rk/_defaults
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,9 @@ riemann = HLLC ; HLLC or CGF
well_balanced = 0 ; use a well-balanced scheme to keep the model in hydrostatic equilibrium


[sponge]
do_sponge = 0 ; do we include a sponge source term

sponge_rho_begin = 1.e-2 ; density below which to begin the sponge
sponge_rho_full = 1.e-3 ; density below which the sponge is fully enabled
sponge_timescale = 1.e-2 ; the timescale over which the sponge should act
7 changes: 7 additions & 0 deletions pyro/compressible_rk/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ def substep(self, myd):
(flux_x.v(n=n) - flux_x.ip(1, n=n))/myg.dx + \
(flux_y.v(n=n) - flux_y.jp(1, n=n))/myg.dy + S.v(n=n)

# finally, add the sponge source, if desired
if self.rp.get_param("sponge.do_sponge"):
kappa_f = compressible.get_sponge_factor(myd.data, self.ivars, self.rp, myg)

k.v(n=self.ivars.ixmom)[:, :] -= kappa_f.v() * myd.data.v(n=self.ivars.ixmom)
k.v(n=self.ivars.iymom)[:, :] -= kappa_f.v() * myd.data.v(n=self.ivars.iymom)

return k

def method_compute_timestep(self):
Expand Down
8 changes: 8 additions & 0 deletions pyro/compressible_sdc/_defaults
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,11 @@ temporal_method = RK4 ; integration method (see mesh/integration.py)
grav = 0.0 ; gravitational acceleration (in y-direction)

riemann = CGF


[sponge]
do_sponge = 0 ; do we include a sponge source term

sponge_rho_begin = 1.e-2 ; density below which to begin the sponge
sponge_rho_full = 1.e-3 ; density below which the sponge is fully enabled
sponge_timescale = 1.e-2 ; the timescale over which the sponge should act

0 comments on commit 4a074a6

Please sign in to comment.