Skip to content

Commit

Permalink
use a seeded random number generator for convection (#310)
Browse files Browse the repository at this point in the history
we use a random velocity field at initialization
this makes the problem reproducible
  • Loading branch information
zingale authored Jan 8, 2025
1 parent f73c3e0 commit 1289879
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pyro/compressible/problems/convection.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ def init_data(my_data, rp):
ymom[:, :] = 0.0
dens[:, :] = dens_cutoff

# create a seeded random number generator
rng = np.random.default_rng(12345)

# set the density to be stratified in the y-direction
myg = my_data.grid

Expand Down Expand Up @@ -75,7 +78,7 @@ def init_data(my_data, rp):
ener[:, :] = p[:, :]/(gamma - 1.0)

# pairs of random numbers between [-1, 1]
vel_pert = 2.0 * np.random.random_sample((myg.qx, myg.qy, 2)) - 1
vel_pert = 2.0 * rng.random(size=(myg.qx, myg.qy, 2)) - 1

cs = np.sqrt(gamma * p / dens)

Expand Down

0 comments on commit 1289879

Please sign in to comment.