-
Notifications
You must be signed in to change notification settings - Fork 6
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 utilities for parsing gmso forcefields XML. Closes #4 #5
Conversation
Codecov Report
@@ Coverage Diff @@
## main #5 +/- ##
==========================================
+ Coverage 86.60% 90.84% +4.23%
==========================================
Files 9 12 +3
Lines 702 1322 +620
==========================================
+ Hits 608 1201 +593
- Misses 94 121 +27
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this looks good! Have a few questions, but nothing major. I think this is ready to be merged (or after you add the remaining test @umesh-timalsina)
Depends on mosdef-hub/gmso#681 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Going to push a few tests here and in GMSO for handling the reading for these functions. We should wait on this until those are all implemented. I think we're going to transition in the next week to a full dependency on forcefield-utilities for GMSO.
|
||
if ( | ||
torsion_type.type1 | ||
and torsion_type.type2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't work if the type or class is only partially defined e.g.
<DihedralType name="DihedralType1" type1="" type2="C" type3="C" type4="">
We need to switch the and
's for or
's here to check if any one is defined.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@CalCraven Good catch. I think we need an alternative approach where in the default value is populated as a *
and this check should stay as is.
mosdef-hub/gmso#681 is merged. |
I'm having an issue with the defaults unyts |
def test_ffutils_backend(self):
ff = ForceField()
> ff.load_backend_forcefield_utilities(get_path("ff-example0.xml"))
self = FFMetaData(children=[Units(energy='K*kb', distance='nm', mass='amu', charge='coulomb', temperature=None, angle=None, time=None)], electrostatics14Scale=0.5, nonBonded14Scale=0.67, combining_rule='lorentz')
def get_default_units(self):
units_dict = {}
units = self.children[0].dict(by_alias=True, exclude_none=True)
for name, unit in units.items():
try:
units_dict[name] = u.Unit(unit)
except u.exceptions.UnitParseError:
> units_dict[name] = getattr(u.physical_constants, unit)
E AttributeError: module 'unyt.physical_constants' has no attribute 'K*kb'
def load_backend_forcefield_utilities(self, filename, backend="forcefield-utilities"):
from forcefield_utilities.xml_loader import GMSOFFs
loader = GMSOFFs()
self = loader.load(filename).to_gmso_ff() |
For now, I will test forcefields in GMSO that don't have the K*kb unit styles. Once this PR is merged, we should fix that functionality. |
@CalCraven I think this is fine to do as long as we define a new unit called >>> import unyt as U
>>> U.define_unit('_kb', 1.0 * U.kb) |
This is still incomplete with duplicates trimming. Because of multiple sections allowed. An alternate strategy is necessary to weedout duplicates. |
To be clear, duplicates means duplicate section headers in the XML. I would expect duplicated sections to just append to that object in the GMSO ForceField class, but if it's going to take a bit more time to implement, I would suggest merging this as is and document that we only support a single section for now, pending a new PR for it. |
Agree with @CalCraven that we should merge this PR in the interest of time, and we can list the remaining to do as issue to be deal with in near future. |
I am working on an |
No description provided.