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

Loading for XMLS bug #682

Closed
CalCraven opened this issue Jul 28, 2022 · 4 comments
Closed

Loading for XMLS bug #682

CalCraven opened this issue Jul 28, 2022 · 4 comments
Labels
ForceField Anything due with the ForceField object

Comments

@CalCraven
Copy link
Contributor

Seems to be an issue with loading certain GMSO style xmls, which may be created from an older version of GMSO that provided less information than the current implementations assume.

Code to reproduce the bug:

import gmso
ff = gmso.ForceField("./opls_charmm_buck.xml") # forcefield attached
print(dihedtype.parameters for dihed in ff.dihedral_types.values())
ff.to_xml("tmp.xml")

Output:

dict_values([unyt_quantity(0.6276, '1.660538921e-21*J'), unyt_quantity(1.8828, '1.660538921e-21*J'), unyt_quantity(0., '1.660538921e-21*J'), unyt_quantity(-3.21331, '1.660538921e-21*J'), unyt_quantity(0., '1.660538921e-21*J'), unyt_quantity(0., '1.660538921e-21*J')])
dict_values([[unyt_quantity(0., '1000.0*J')], [unyt_quantity(1., '(dimensionless)')], [unyt_quantity(0., '0.0174532925199433*rad')]])

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Input In [21], in <module>
----> 1 ff.to_xml("tmp.xml")

File ~/Dropbox/Mac/Documents/Vanderbilt/Research/MoSDeF/gmso/gmso/core/forcefield.py:578, in ForceField.to_xml(self, filename, overwrite)
    576     params_units_def = {}
    577     for param, value in potential.parameters.items():
--> 578         params_units_def[param] = value.units
    579         etree.SubElement(
    580             potential_group,
    581             "ParametersUnitDef",
   (...)
    585             },
    586         )
    588 potential_group.append(potential.etree(params_units_def))

AttributeError: 'list' object has no attribute 'units'

As you can see, the charmm_proper_1 style are being stored as a list of lists, instead of as a list of unyts (this is the second dihedral in the output, as compared to the first one which is stored correctly).

@CalCraven
Copy link
Contributor Author

xmls.zip

@CalCraven
Copy link
Contributor Author

So I think this issue can be readdressed once PR #674 is merged. Essentially the issue is the lists of allowed parameters, which are read properly but not written out properly.

@CalCraven
Copy link
Contributor Author

xmls.zip

@daico007 daico007 added the ForceField Anything due with the ForceField object label Aug 24, 2022
@CalCraven
Copy link
Contributor Author

I just retested this, I think this issue has actually been resolved.

import gmso
ff = gmso.ForceField("./opls_charmm_buck.xml") # forcefield attached
ff.to_xml("tmp.xml")
new_ff = gmso.ForceField("tmp.xml") # works
assert new_ff == ff

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ForceField Anything due with the ForceField object
Projects
None yet
Development

No branches or pull requests

2 participants