From 128987909d19203c792e27d827d93fd76f7d5eaa Mon Sep 17 00:00:00 2001 From: Michael Zingale Date: Wed, 8 Jan 2025 15:57:16 -0500 Subject: [PATCH] use a seeded random number generator for convection (#310) we use a random velocity field at initialization this makes the problem reproducible --- pyro/compressible/problems/convection.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pyro/compressible/problems/convection.py b/pyro/compressible/problems/convection.py index 90768cd74..8b8b53872 100644 --- a/pyro/compressible/problems/convection.py +++ b/pyro/compressible/problems/convection.py @@ -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 @@ -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)