Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix system.part choice for Gibbs sample #4283

Merged
merged 2 commits into from
Jun 23, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions samples/gibbs_ensemble/gibbs_ensemble.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()

Expand Down
2 changes: 1 addition & 1 deletion samples/gibbs_ensemble/run_sim.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down