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

Support GSD >= 2.9 #1131

Merged
merged 3 commits into from
Jun 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions environment-dev-win.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ dependencies:
- gmso>=0.9.0
- foyer>=0.11.0
- garnett>=0.7.1
- gsd>=1.2
- gsd>=2.9
- intermol
- mdtraj
- networkx
- nglview>=2.7
- numpy
- numpy=1.24.2
- openbabel>=3.0.0
- packmol=1!18.013
- parmed>=3.4.3
Expand Down
4 changes: 2 additions & 2 deletions environment-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ dependencies:
- foyer>=0.11.0
- freud>=2.0.0
- garnett>=0.7.1
- gsd>=2
- gsd>=2.9
- hoomd>=3
- intermol
- mdtraj
- networkx
- nglview>=3
- numpy
- numpy=1.24.2
- openbabel>=3
- packmol>=20
- parmed>=3.4.3
Expand Down
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ channels:
- conda-forge
dependencies:
- ele
- numpy
- numpy=1.24.2
- packmol>=18
- gmso>=0.9.0
- parmed>=3.4.3
Expand Down
4 changes: 2 additions & 2 deletions mbuild/formats/gsdwriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def write_gsd(
if shift_coords:
xyz = coord_shift(xyz, structure.box[:3])

gsd_snapshot = gsd.hoomd.Snapshot()
gsd_snapshot = gsd.hoomd.Frame()

gsd_snapshot.configuration.step = 0
gsd_snapshot.configuration.dimensions = 3
Expand Down Expand Up @@ -101,7 +101,7 @@ def write_gsd(
if structure.rb_torsions:
_write_dihedral_information(gsd_snapshot, structure)

with gsd.hoomd.open(filename, mode="wb") as gsd_file:
with gsd.hoomd.open(filename, mode="w") as gsd_file:
gsd_file.append(gsd_snapshot)


Expand Down
4 changes: 2 additions & 2 deletions mbuild/formats/hoomd_snapshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ def _get_hoomd_version():
def from_snapshot(snapshot, scale=1.0):
"""Convert a Snapshot to a Compound.

Snapshot can be a hoomd.Snapshot or a gsd.hoomd.Snapshot.
Snapshot can be a hoomd.Snapshot or a gsd.hoomd.Frame.

Parameters
----------
snapshot : hoomd.Snapshot or gsd.hoomd.Snapshot
snapshot : hoomd.Snapshot or gsd.hoomd.Frame
Snapshot from which to build the mbuild Compound.
scale : float, optional, default 1.0
Value by which to scale the length values
Expand Down
9 changes: 0 additions & 9 deletions mbuild/tests/test_compound.py
Original file line number Diff line number Diff line change
Expand Up @@ -2360,15 +2360,6 @@ def test_from_rdkit_smiles(self, test_smiles):
np.diff(np.vstack(pos).reshape(len(pos), -1), axis=0) == 0
).all()

@pytest.mark.parametrize("bad_smiles", ["F[P-](F)(F)(F)(F)F"])
@pytest.mark.skipif(not has_rdkit, reason="RDKit is not installed")
def test_incorrect_rdkit_smiles(self, bad_smiles):
with pytest.raises(
MBuildError,
match=r"RDKit was unable to generate " r"3D coordinates",
):
mb.load(bad_smiles, smiles=True, backend="rdkit", seed=29)

@pytest.mark.skipif(not has_openbabel, reason="Pybel is not installed")
def test_get_smiles(self):
test_strings = ["CCO", "CCCCCCCC", "c1ccccc1", "CC(=O)Oc1ccccc1C(=O)O"]
Expand Down
18 changes: 9 additions & 9 deletions mbuild/tests/test_gsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def test_particles(self, ethane):
from mbuild.utils.sorting import natural_sort

ethane.save(filename="ethane.gsd", forcefield_name="oplsaa")
with gsd.hoomd.open("ethane.gsd", mode="rb") as f:
with gsd.hoomd.open("ethane.gsd", mode="r") as f:
frame = f[0]

assert frame.configuration.step == 0
Expand Down Expand Up @@ -88,7 +88,7 @@ def test_box(self, ethane):
ethane.box = Box(lengths=[2.0, 3.0, 4.0])

ethane.save(filename="ethane.gsd", forcefield_name="oplsaa")
with gsd.hoomd.open("ethane.gsd", mode="rb") as f:
with gsd.hoomd.open("ethane.gsd", mode="r") as f:
frame = f[0]

box_from_gsd = frame.configuration.box.astype(float)
Expand All @@ -101,7 +101,7 @@ def test_box(self, ethane):

ethane.periodicity = (True, True, True)
ethane.save(filename="ethane-periodicity.gsd", forcefield_name="oplsaa")
with gsd.hoomd.open("ethane-periodicity.gsd", mode="rb") as f:
with gsd.hoomd.open("ethane-periodicity.gsd", mode="r") as f:
frame = f[0]
box_from_gsd_periodic = frame.configuration.box.astype(float)
assert np.array_equal(box_from_gsd, box_from_gsd_periodic)
Expand All @@ -111,7 +111,7 @@ def test_box(self, ethane):
ethane.save(
filename="triclinic-box.gsd", forcefield_name="oplsaa", box=box
)
with gsd.hoomd.open("triclinic-box.gsd", mode="rb") as f:
with gsd.hoomd.open("triclinic-box.gsd", mode="r") as f:
frame = f[0]
lx, ly, lz, xy, xz, yz = frame.configuration.box

Expand All @@ -131,7 +131,7 @@ def test_rigid(self, benzene):

benzene.label_rigid_bodies(rigid_particles="C")
benzene.save(filename="benzene.gsd", forcefield_name="oplsaa")
with gsd.hoomd.open("benzene.gsd", mode="rb") as f:
with gsd.hoomd.open("benzene.gsd", mode="r") as f:
frame = f[0]

rigid_bodies = frame.particles.body
Expand All @@ -150,7 +150,7 @@ def test_bonded(self, ethane):
from foyer import Forcefield

ethane.save(filename="ethane.gsd", forcefield_name="oplsaa")
with gsd.hoomd.open("ethane.gsd", mode="rb") as f:
with gsd.hoomd.open("ethane.gsd", mode="r") as f:
frame = f[0]

structure = ethane.to_parmed()
Expand Down Expand Up @@ -244,7 +244,7 @@ def test_pairs(self, benzene):
from foyer import Forcefield

benzene.save(filename="benzene.gsd", forcefield_name="oplsaa")
with gsd.hoomd.open("benzene.gsd", mode="rb") as f:
with gsd.hoomd.open("benzene.gsd", mode="r") as f:
frame = f[0]

structure = benzene.to_parmed()
Expand Down Expand Up @@ -273,7 +273,7 @@ def test_units(self, ethane):
ref_mass=ref_mass,
box=box,
)
with gsd.hoomd.open("ethane.gsd", mode="rb") as f:
with gsd.hoomd.open("ethane.gsd", mode="r") as f:
frame = f[0]

box_from_gsd = frame.configuration.box.astype(float)
Expand Down Expand Up @@ -312,7 +312,7 @@ def test_box_dimensions(self, benzene):
benzene, n_compounds=n_benzenes, box=[0, 0, 0, 4, 4, 4]
)
filled.save(filename="benzene.gsd")
with gsd.hoomd.open("benzene.gsd", mode="rb") as f:
with gsd.hoomd.open("benzene.gsd", mode="r") as f:
frame = f[0]
positions = frame.particles.position.astype(float)
for coords in positions:
Expand Down
2 changes: 1 addition & 1 deletion mbuild/tests/test_hoomd.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def test_compound_from_gsdsnapshot(self, ethane):
snap, _ = to_hoomdsnapshot(filled)

# copy attributes from the snapshot to a gsd snapshot
gsd_snap = gsd.hoomd.Snapshot()
gsd_snap = gsd.hoomd.Frame()
gsd_snap.particles.N = snap.particles.N
gsd_snap.particles.types = snap.particles.types
gsd_snap.particles.typeid = snap.particles.typeid
Expand Down
Loading