Open ntBre opened 1 year ago
I don't recall if cosmetic attributes are meant to be serialized out - the docstring of ForceField.to_file
implies they are by default.
Is this an issue with just AngleHandler
and/or parameterize
? Does the same thing happen with other cosmetic attributes?
I don't recall if cosmetic attributes are meant to be serialized out - the docstring of ForceField.to_file implies they are by default.
Yes, having discard_cosmetic_attributes=False
by default implies to me that they should be written out as faithfully as possible.
Does the same thing happen with other cosmetic attributes?
This feels like more of #1633 and #1493, where I think the current fix so far only safeguards specific ParameterAttributes so everything else, including cosmetics, is fair game.
>>> from openff.toolkit import ForceField
>>> ff = ForceField("/Users/lily/Downloads/input.offxml", allow_cosmetic_attributes=True)
>>> handler = ff.get_parameter_handler("Angles")
>>> handler.parameters[15]._parameterize
1 boltzmann_constant
>>> handler.parameters[14]._parameterize
'k, angle'
This only happens with parameters where parameterize="k"
, as the toolkit correctly interprets parameterize="k, length"
as a string.
Agreed - The right resolution for this would be to not convert cosmetics - There's no safe way to encode that those should be quantities vs. strings, so we should always treat them as strings. I'll accept a PR that changes this, or will get to it myself after my current backlog!
There's #1637, but #1641 is still an issue.
Describe the bug Parsing a ForceField and rewriting it a to file changes the
parameterize
field on some Angles fromk
to1 * boltzmann_constant ** 1
, upsetting ForceBalance.To Reproduce I needed to remove the Constraints section of a ForceField for ForceBalance and got this suggestion from Lily:
But I can reproduce it even with the
deregister_parameter_handler
line commented out. The changes are clearly seen when runningdiff input.offxml output.xml
or even just grepping for boltzmann in both files.Output
Computing environment (please complete the following information):
conda list
(important part is openff-toolkit 0.14.0, but I reproduced on 0.13.2 too):