Skip to content

Commit 1289879

Browse files
authored
use a seeded random number generator for convection (#310)
we use a random velocity field at initialization this makes the problem reproducible
1 parent f73c3e0 commit 1289879

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

pyro/compressible/problems/convection.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ def init_data(my_data, rp):
4242
ymom[:, :] = 0.0
4343
dens[:, :] = dens_cutoff
4444

45+
# create a seeded random number generator
46+
rng = np.random.default_rng(12345)
47+
4548
# set the density to be stratified in the y-direction
4649
myg = my_data.grid
4750

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

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

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

0 commit comments

Comments
 (0)