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

fixed error in verbose mode for missing dihedrals #335

Merged
merged 3 commits into from
Jun 12, 2020
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
34 changes: 25 additions & 9 deletions foyer/forcefield.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,22 +310,38 @@ def _check_dihedrals(data, structure, verbose,
if verbose:
for omm_ids in data.propers:
missing_dihedral = True
for pmd_proper in proper_dihedrals:
pmd_ids = (pmd_proper.atom1.idx, pmd_proper.atom2.idx, pmd_proper.atom3.idx, pmd_proper.atom4.idx)
if pmd_ids == omm_ids:
missing_dihedral = False
for pmd_proper in structure.rb_torsions:
pmd_ids = (pmd_proper.atom1.idx, pmd_proper.atom2.idx, pmd_proper.atom3.idx, pmd_proper.atom4.idx)
if pmd_ids == omm_ids:
missing_dihedral = False
if missing_dihedral:
print('missing improper with ids {}'.format(pmd_ids))
print("Missing dihedral with ids {} and types {}.".format(
omm_ids, [structure.atoms[idx].type for idx in omm_ids]))

if data.propers and len(data.propers) != \
len(proper_dihedrals) + len(structure.rb_torsions):
msg = ("Parameters have not been assigned to all proper dihedrals. "
"Total system dihedrals: {}, Parameterized dihedrals: {}. "
"Note that if your system contains torsions of Ryckaert-"
"Bellemans functional form, all of these torsions are "
"processed as propers.".format(len(data.propers),
len(proper_dihedrals) + len(structure.rb_torsions)))
_error_or_warn(assert_dihedral_params, msg)
len(proper_dihedrals) + len(structure.rb_torsions):
if data.propers and len(data.propers) < \
len(proper_dihedrals) + len(structure.rb_torsions):
msg = ("Parameters have been assigned to all proper dihedrals. "
"However, there are more parameterized dihedrals ({}) "
"than total system dihedrals ({}). "
"This may be due to having multiple periodic dihedrals "
"for a single system dihedral.".format(len(proper_dihedrals) +
len(structure.rb_torsions),
len(data.propers)))
warnings.warn(msg)
else:
msg = ("Parameters have not been assigned to all proper dihedrals. "
"Total system dihedrals: {}, Parameterized dihedrals: {}. "
"Note that if your system contains torsions of Ryckaert-"
"Bellemans functional form, all of these torsions are "
"processed as propers.".format(len(data.propers),
len(proper_dihedrals) + len(structure.rb_torsions)))
_error_or_warn(assert_dihedral_params, msg)

improper_dihedrals = [dihedral for dihedral in structure.dihedrals
if dihedral.improper]
Expand Down