Skip to content

Commit

Permalink
Report missing bonds' types when using verbose flag (#486)
Browse files Browse the repository at this point in the history
  • Loading branch information
jennyfothergill authored Jan 17, 2022
1 parent 98f0edf commit c5802ba
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions foyer/forcefield.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,11 +348,19 @@ def _error_or_warn(error, msg):
warnings.warn(msg)


def _check_bonds(data, structure, assert_bond_params):
def _check_bonds(data, structure, verbose, assert_bond_params):
"""Check if any bonds lack paramters."""
if data.bonds:
missing = [b for b in structure.bonds if b.type is None]
if missing:
if verbose:
for bond in missing:
a1 = bond.atom1
a2 = bond.atom2
print(
f"Missing bond with ids {(a1.idx, a2.idx)} and types "
f"{[a1.type, a2.type]}."
)
nmissing = len(structure.bonds) - len(missing)
msg = (
"Parameters have not been assigned to all bonds. "
Expand Down Expand Up @@ -859,7 +867,7 @@ def parametrize_system(
if box_vectors is not None:
structure.box_vectors = box_vectors

_check_bonds(data, structure, assert_bond_params)
_check_bonds(data, structure, verbose, assert_bond_params)
_check_angles(data, structure, verbose, assert_angle_params)
_check_dihedrals(
data,
Expand Down

0 comments on commit c5802ba

Please sign in to comment.