mosdef-hub / foyer

A package for atom-typing as well as applying and disseminating forcefields
https://foyer.mosdef.org
MIT License
117 stars 76 forks source link

The General Forcefield will not work with GMSO dev branch. #510

Closed CalCraven closed 1 year ago

CalCraven commented 2 years ago

Bug summary

What were you trying to do and what happened instead? Please copy and paste the stack output Code to reproduce the behavior

from foyer import general_forcefield
opls_alkane_gmso = general_forcefield.Forcefield(forcefield_files='xml_files/oplsaa_alkanes.xml', strict=False)
typed_gmso = opls_alkane_gmso.apply(compound, assert_improper_params=False, 
                                    assert_dihedral_params=False, debug=False)
typed_gmso.save('test3.top', overwrite=True)

AttributeError Traceback (most recent call last) /tmp/ipykernel_268/3849429905.py in 4 5 typed_gmso = opls_alkane_gmso.apply(compound, assert_improper_params=False, ----> 6 assert_dihedral_params=False, debug=False) 7 8 typed_gmso.save('test3.top', overwrite=True)

/srv/conda/envs/notebook/lib/python3.7/site-packages/foyer/general_forcefield.py in apply(self, top, references_file, use_residue_map, assert_bond_params, assert_angle_params, assert_dihedral_params, assert_improper_params, combining_rule, debug, remove_untyped_connections, *args, *kwargs) 249 remove_untyped_connections=remove_untyped_connections, 250 args, --> 251 **kwargs, 252 ) 253

/srv/conda/envs/notebook/lib/python3.7/site-packages/foyer/general_forcefield.py in _parametrize(self, top, typemap, references_file, assert_bond_params, assert_angle_params, assert_dihedral_params, assert_improper_params, combining_rule, debug, remove_untyped_connections, **kwargs) 343 if self.backend == "gmso": 344 self._parametrize_gmsoFF( --> 345 top=top, typemap=typemap, combining_rule=combining_rule 346 ) 347 else:

/srv/conda/envs/notebook/lib/python3.7/site-packages/foyer/general_forcefield.py in _parametrize_gmsoFF(self, top, typemap, combining_rule) 394 for key in self.ff.scaling_factors.keys(): 395 msg = f"Incorrect scaling_factors key word provided: {key}" --> 396 assert key in top.scaling_factors.keys(), msg 397 top.scaling_factors.update(self.ff.scaling_factors) 398 return top

AttributeError: 'numpy.ndarray' object has no attribute 'keys'

Please include a code snippet that can be used to reproduce this bug.

The issue is due to the different handling of scaling factors in the gmso topology. This will have to be addressed in the future.

CalCraven commented 1 year ago

Close with PR #512.