Skip to content

Commit

Permalink
Fix unstable Python_particle_attr_access CI tests (ECP-WarpX#2766)
Browse files Browse the repository at this point in the history
* explicitly set the numpy random seed in Python_particle_attr_access tests

* also shrink boundaries in which particles are injected for good measure

* also explicitly set the numpy random seed in Python_restart_runtime_components CI test
  • Loading branch information
roelof-groenewald authored Jan 20, 2022
1 parent cd3488e commit 1087dd1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
8 changes: 5 additions & 3 deletions Examples/Tests/ParticleDataPython/PICMI_inputs_2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
ymin = 0
ymax = 0.03


##########################
# numerics components
##########################
Expand Down Expand Up @@ -105,6 +104,9 @@
# python particle data access
##########################

# set numpy random seed so that the particle properties generated
# below will be reproducible from run to run
np.random.seed(30025025)

sim.extension.add_real_comp('electrons', 'newPid')

Expand All @@ -113,9 +115,9 @@
def add_particles():

nps = 10 * (my_id + 1)
x = np.random.rand(nps) * 0.03
x = np.linspace(0.005, 0.025, nps)
y = np.zeros(nps)
z = np.random.random(nps) * 0.03
z = np.linspace(0.005, 0.025, nps)
ux = np.random.normal(loc=0, scale=1e3, size=nps)
uy = np.random.normal(loc=0, scale=1e3, size=nps)
uz = np.random.normal(loc=0, scale=1e3, size=nps)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,18 @@
# python particle data access
##########################

# set numpy random seed so that the particle properties generated
# below will be reproducible from run to run
np.random.seed(30025025)

sim.extension.add_real_comp('electrons', 'newPid')

def add_particles():

nps = 10
x = np.random.rand(nps) * 0.03
x = np.linspace(0.005, 0.025, nps)
y = np.zeros(nps)
z = np.random.random(nps) * 0.03
z = np.linspace(0.005, 0.025, nps)
ux = np.random.normal(loc=0, scale=1e3, size=nps)
uy = np.random.normal(loc=0, scale=1e3, size=nps)
uz = np.random.normal(loc=0, scale=1e3, size=nps)
Expand Down

0 comments on commit 1087dd1

Please sign in to comment.