You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When building a molecule and initializing the system, if we call the apply_forcefield() function with a forcefield and then call it again with a different forcefield, this error pops up:
"Forcefield is not provided. Valid forcefield must be provided either during Molecule initialization or when calling the "
"`apply_forcefield` method of the System class."
Here's the code to replicate the error:
from flowermd.base import Molecule, Pack
from flowermd.library import OPLS_AA, GAFF
mol = Molecule(num_mols=1, smiles="CCC")
system = Pack(molecules=mol, density=0.5, packing_expand_factor=5)
system.apply_forcefield(r_cut=2.5, force_field=OPLS_AA(), auto_scale=True, scale_charges=True)
system.apply_forcefield(r_cut=2.5, force_field=GAFF(), auto_scale=True, scale_charges=True)
Potential cause:
This error is coming from the _validate_forcefield(). When a forcefield is specified for the first time, that forcefield will be added to self._gmso_forcefields_dict in the system class. If we try to rerun the apply_forcefield() with a different forcefield, there will be a mistmatch between that dictionary and the new forcefield. That will cause the exception to raise. We originally put that check so that users stick to the same forcefield during initialization. This would make sense when the apply_forcefield() function did parameterize the system correctly.
However, for a case where the apply_forcefield() didn't work the first time (due to some missing parameter in opls ff) and user wants to try a different ff like GAFF, that's where this becomes an issue. This is the scenario that Lauren @lestes1118 tried and got this error.
My first suggestion is to re-evaluate the _validate_forcefield() function and make sure the checks are still valid, specially since we changed the apply_forcefield() interface a few times before finalizing it.
The text was updated successfully, but these errors were encountered:
Bug description:
When building a molecule and initializing the system, if we call the
apply_forcefield()
function with a forcefield and then call it again with a different forcefield, this error pops up:Here's the code to replicate the error:
Potential cause:
This error is coming from the
_validate_forcefield()
. When a forcefield is specified for the first time, that forcefield will be added toself._gmso_forcefields_dict
in the system class. If we try to rerun theapply_forcefield()
with a different forcefield, there will be a mistmatch between that dictionary and the new forcefield. That will cause the exception to raise. We originally put that check so that users stick to the same forcefield during initialization. This would make sense when theapply_forcefield()
function did parameterize the system correctly.However, for a case where the
apply_forcefield()
didn't work the first time (due to some missing parameter in opls ff) and user wants to try a different ff like GAFF, that's where this becomes an issue. This is the scenario that Lauren @lestes1118 tried and got this error.My first suggestion is to re-evaluate the
_validate_forcefield()
function and make sure the checks are still valid, specially since we changed theapply_forcefield()
interface a few times before finalizing it.The text was updated successfully, but these errors were encountered: