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

Add check_box_size option for add method in Compound.add() #1149

Merged
merged 4 commits into from
Oct 22, 2023
Merged
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
12 changes: 10 additions & 2 deletions mbuild/compound.py
Original file line number Diff line number Diff line change
Expand Up @@ -815,6 +815,7 @@ def add(
inherit_periodicity=None,
inherit_box=False,
reset_rigid_ids=True,
check_box_size=True,
):
"""Add a part to the Compound.

Expand Down Expand Up @@ -843,6 +844,8 @@ def add(
rigid_ids such that values remain distinct from rigid_ids
already present in `self`. Can be set to False if attempting
to add Compounds to an existing rigid body.
check_box_size : bool, optional, default=True
Checks and warns if compound box is smaller than its bounding box after adding new_child.
"""
# Support batch add via lists, tuples and sets.
# If iterable, we will first compose all the bondgraphs of individual
Expand Down Expand Up @@ -891,9 +894,14 @@ def add(
child,
label=label_list[i],
reset_rigid_ids=reset_rigid_ids,
check_box_size=False,
)
else:
self.add(child, reset_rigid_ids=reset_rigid_ids)
self.add(
child,
reset_rigid_ids=reset_rigid_ids,
check_box_size=False,
)

return

Expand Down Expand Up @@ -995,7 +1003,7 @@ def add(
)

# Check that bounding box is within box after adding compound
if self.box:
if self.box and check_box_size:
if (
np.array(self.box.lengths)
< np.array(self.get_boundingbox().lengths)
Expand Down
Loading