mosdef-hub / gmso

Flexible storage of chemical topology for molecular simulation
https://gmso.mosdef.org
MIT License
53 stars 32 forks source link

JSON handling for parameterized topologies #795

Closed CalCraven closed 6 months ago

CalCraven commented 6 months ago

Seems like there's an issue saving the JSON state of a topology, where the parameters aren't stored at all. Maybe this is a good place to discuss if that's a feature we would want to have.

import gmso
from gmso.parameterization import apply
top = gmso.Topology.load("ethane.json")
assert not top.is_typed()
ff = gmso.ForceField("ethane.xml")
ptop = apply(top, ff, identify_connections=True)
assert ptop.is_typed()
ptop.save("ethane-typed.json")
newtop = gmso.Topology("ethane-typed.json")
print(newtop.is_typed("topology"))

output

False
daico007 commented 6 months ago

I think this is already supported, likely need to change the default options and clarify the documentation for this method (https://github.com/mosdef-hub/gmso/blob/main/gmso/formats/json.py#L24-L42)

CalCraven commented 6 months ago

You're right. However, maybe we should make this clear at the topology.save() documentation, because that's the standard way to write things out and it's easy to miss that only a partial topology was saved without the keyword.

daico007 commented 6 months ago

Yes, totally support changing the default to True (for saving out a typed structure)

daico007 commented 6 months ago

This has been updated in the latest commit in https://github.com/mosdef-hub/gmso/pull/794

daico007 commented 6 months ago

Addressed in #794