Skip to content

Commit 861b49b

Browse files
authored
Merge pull request #2206 from mzbush/fix-mpcd-test
Fix mpcd particle positions
2 parents 3ad0498 + 5c02723 commit 861b49b

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

hoomd/mpcd/pytest/test_collide.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ def test_run(self, small_snap, simulation_factory, cls, init_args):
139139
"angmom_rigid", [[0, 0, 0, 0], [0, 2, 3, 4]], ids=["Nonrotating", "Rotating"]
140140
)
141141
@pytest.mark.parametrize(
142-
"pos_rigid", [[0, 0, 0], [10, 10, 10]], ids=["center", "edge"]
142+
"pos_rigid", [[0, 0, 0], [5, 5, 5]], ids=["center", "edge"]
143143
)
144144
@pytest.mark.parametrize(
145145
"def_rigid,properties_rigid",
@@ -208,6 +208,7 @@ def test_rigid_collide(
208208
):
209209
if "kT" not in init_args:
210210
init_args["kT"] = 1.0
211+
L = 11 # length of box
211212

212213
N_mpcd = len(def_rigid["constituent_types"])
213214
rng = np.random.default_rng(seed=42)
@@ -216,7 +217,7 @@ def test_rigid_collide(
216217

217218
# create simulation
218219
initial_snap = one_particle_snapshot_factory(
219-
particle_types=["A", "B"], position=pos_rigid, L=21
220+
particle_types=["A", "B"], position=pos_rigid, L=L
220221
)
221222
total_mass = properties_rigid["mass"][0]
222223
if initial_snap.communicator.rank == 0:
@@ -225,10 +226,13 @@ def test_rigid_collide(
225226
initial_snap.particles.velocity[:] = [velo_rigid]
226227
initial_snap.particles.angmom[:] = [angmom_rigid]
227228

228-
# place the mpcd particles on top of constituents
229+
# place the mpcd particles on top of constituents, accounting for PBCs
230+
positions = np.add(def_rigid["positions"], pos_rigid)
231+
positions[positions < -L * 0.5] = positions[positions < -L * 0.5] + L
232+
positions[positions > L * 0.5] = positions[positions > L * 0.5] - L
229233
initial_snap.mpcd.N = N_mpcd
230234
initial_snap.mpcd.types = ["C"]
231-
initial_snap.mpcd.position[:] = def_rigid["positions"]
235+
initial_snap.mpcd.position[:] = positions
232236
initial_snap.mpcd.velocity[:] = velo_mpcd
233237

234238
sim = simulation_factory(initial_snap)
@@ -338,7 +342,7 @@ def test_rigid_collide_free(
338342
# create simulation
339343
total_mass = properties_rigid["mass"][0]
340344
initial_snap = two_particle_snapshot_factory(
341-
particle_types=["A", "B", "C", "D"], L=21
345+
particle_types=["A", "B", "C", "D"], L=11
342346
)
343347
if initial_snap.communicator.rank == 0:
344348
# put a free particle that doesn't participate in collision on top of

0 commit comments

Comments
 (0)