Closed chrisjonesBSU closed 3 years ago
Here is what I think is happening:
shift_coords = True
in hoomd_snapshot.py
it shifts everything by half of the box length, so that the coordinates of everything spans from -L/2 to L/2. I think that when a particle is near the center of the box, it is then being moved right on or near one of the box boundaries.shift_coords
is set to False
then the particles aren't shifted, but the box generated by Hoomd is still -L/2 to L/2, so we still get particle out of box errors, but they aren't right on one of the box boundaries.I'm not really sure how or where the box is being generated as -L/2 to L/2. that is one potential fix.
A couple other ideas:
Try to update the box size after particles are shifted, make it just a little bit larger
There might be an option to wrap the coordinates somewhere in mBuild and/or Hoomd
I think I've found a solution; temporary at least..
In hoomd_snapshot.py
I just multiplied the shifted xyz postions by a number really close to, but less than 1. This should move any particle that is right on the cusp of the box to just slightly inside. So far, it is no longer resulting in particle out of box errors.
The relevant bit of code in hoomd_snapshot.py
:
xyz = np.array([[atom.xx, atom.xy, atom.xz] for atom in structure.atoms])
if shift_coords:
xyz = coord_shift(xyz, structure.box[:3]) --> This can result in particles on box edge or just slightly over
xyz *= 0.98 --> The fix, moves everything back in a little bit.
I'll open up an issue in mBuild for this. Maybe this isn't the ultimate solution, but it will be worth bringing up.
I think for now, the fix for this is to install from my fork of mbuild. I'll create the fork, add the fix and update the install instructions and environment.yml
file to install mbuild from that fork. I'll raise an issue in mBuild, but we'll see how long it takes before its implemented.
Solved by PR #12
I keep getting particle out of box errors (they are pretty much sitting on the boundaries of the box)
Hoomd errors out before a simulation is started, it looks like it happens when trying to read the snapshot. So, the issue might lie somewhere in mbuild's
hoomd_snapshot.py
when preparing the snapshot.