Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:mosdef-hub/gmso into fix/write_gsd
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisjonesBSU committed Aug 2, 2022
2 parents 3ac2565 + 0a11627 commit 2ec890a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
4 changes: 3 additions & 1 deletion gmso/external/convert_mbuild.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def from_mbuild(
Valid functions are element_by_symbol, element_by_name,
element_by_atomic_number, and element_by_mass, which can be imported
from `gmso.core.element'
parse_label : bool, optional, default=False
parse_label : bool, optional, default=True
Option to parse hierarchy info of the compound into system of top label,
including, group, molecule and residue labels.
Expand All @@ -85,6 +85,7 @@ def from_mbuild(
for child in compound.children:
if not child.children:
site = _parse_site(site_map, child, search_method)
site.group = compound.name
top.add_site(site)
else:
for particle in child.particles():
Expand All @@ -93,6 +94,7 @@ def from_mbuild(
top.add_site(site)
else:
site = _parse_site(site_map, compound, search_method)
site.group = compound.name
top.add_site(site)

for b1, b2 in compound.bonds():
Expand Down
9 changes: 9 additions & 0 deletions gmso/tests/test_convert_mbuild.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,3 +174,12 @@ def test_hierarchical_structure(self, hierarchical_top):
assert label in hierarchical_top.unique_site_labels(
"group", name_only=True
)

@pytest.mark.skipif(not has_mbuild, reason="mBuild is not installed")
def test_group_2_level_compound(self):
mb_cpd = mb.Compound(name="_CH4", mass=12)
filled_box = mb.fill_box(mb_cpd, n_compounds=2, density=0.01)
filled_box.name = "group1"
top = from_mbuild(filled_box)
for site in top.sites:
assert site.group == filled_box.name

0 comments on commit 2ec890a

Please sign in to comment.