diff --git a/samples/gibbs_ensemble/gibbs_ensemble.py b/samples/gibbs_ensemble/gibbs_ensemble.py index dda9eb6d06f..6eb26962ef1 100644 --- a/samples/gibbs_ensemble/gibbs_ensemble.py +++ b/samples/gibbs_ensemble/gibbs_ensemble.py @@ -80,7 +80,8 @@ def send_info(self): def move_particle(self, DX_MAX): """ Move random particle inside the box """ - self.old_particle = np.random.choice(self.system.part) + random_particle_id = np.random.choice(self.system.part[:].id) + self.old_particle = self.system.part[random_particle_id] self.old_pos = self.old_particle.pos self.old_particle.pos = self.old_pos + \ (0.5 - np.random.random(size=3)) * DX_MAX @@ -104,7 +105,8 @@ def revert_add_particle(self): def remove_particle(self): """ Remove a random particle """ - self.old_particle = np.random.choice(self.system.part).to_dict() + random_particle_id = np.random.choice(self.system.part[:].id) + self.old_particle = self.system.part[random_particle_id].to_dict() self.system.part[self.old_particle["id"]].remove() self.send_energy() diff --git a/samples/gibbs_ensemble/run_sim.py b/samples/gibbs_ensemble/run_sim.py index b3b8e887132..0de54d692f9 100644 --- a/samples/gibbs_ensemble/run_sim.py +++ b/samples/gibbs_ensemble/run_sim.py @@ -222,7 +222,7 @@ def validate_info(boxes): np.testing.assert_equal( box.num_part, msg[2], - err_msg="Server side box length (actual) differs from client side (desired)") + err_msg="Server side num part (actual) differs from client side (desired)") logging.debug( "Validation correct. Values of {}:\nBox length:\t{}\nNum Part:\t{}.".format( box.box_name, box.box_length, box.num_part))