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

OFF-EP 0003 #23

Closed
wants to merge 3 commits into from
Closed

OFF-EP 0003 #23

wants to merge 3 commits into from

Conversation

mattwthompson
Copy link
Member

@mattwthompson mattwthompson commented Nov 23, 2021

Resolves #8

Copy link

@davidlmobley davidlmobley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a nice extension; as long as it is dead simple to implement, I support it, as it doesn't make things substantially more complex but does addsubstantial additional flexibility.

@SimonBoothroyd
Copy link
Contributor

This is a bit more of a tricky one as it goes against the current philosophy that all attribute names in the spec can mapped into code, so while length_bondorder1 is valid python (/ C / javascript...), length_bondorder1.5 won't be and so cannot be directly accessed.

@j-wags will probably have more thoughts on this though.

Copy link
Member

@jchodera jchodera left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested alternative approach to avoid potential issues with the use of . character in XML attributes (which may cause problems fro other serialization forms).

docs/enhancement-proposals/off-ep-0003.md Outdated Show resolved Hide resolved
docs/enhancement-proposals/off-ep-0003.md Outdated Show resolved Hide resolved
[bond](https://openforcefield.github.io/standards/standards/smirnoff/#fractional-bond-orders) and
[proper
torsion](https://openforcefield.github.io/standards/standards/smirnoff/#fractional-torsion-bond-orders)
forces. The examples provided use bond orders of 1 and 2 and as the basis of interpolation between
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"The examples provided use bond orders of 1 and 2 and as the basis of interpolation between their associated parameters."

This sentence is nonsensical. Was some text omitted between "and" and "as the basis"?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's missing here is jargon for "the x coordinates," like your above "fractional bond order interpolation points." There's also an added "and" that makes is hard to read.

<Bonds version="0.3" potential="harmonic" fractional_bondorder_method="AM1-Wiberg" fractional_bondorder_interpolation="linear">
<Bond
smirks="[#6X3:1]!#[#6X3:2]"
k_bondorder1="820.0*kilocalories_per_mole/angstrom**2"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are XML attributes with the . valid attribute tokens? Would this hold for other serializations, such as YAML, JSON, BSON, etc? I worry this might cause problems.

If not, it would be much easier to specify interpolation points as

k1="820.0*kilocalories_per_mole/angstrom**2" length1="1.45*angstrom" bondorder1="1.0"
k2="1000.0*kilocalories_per_mole/angstrom**2" length2="1.43*angstrom" bondorder2="1.5"
k3="1098*kilocalories_per_mole/angstrom**2" length3="1.35*angstrom" bondorder3="2.0"

If we wanted to maintain backward compatibility, we could use

k_bondorder1="820.0*kilocalories_per_mole/angstrom**2" length_bondorder1="1.45*angstrom" bondorder1="1.0"
k_bondorder2="1000.0*kilocalories_per_mole/angstrom**2" length_bondorder2="1.43*angstrom" bondorder2="1.5"
k_bondorder3="1098*kilocalories_per_mole/angstrom**2" length_bondorder3="1.35*angstrom" bondorder3="2.0"

and have bondorder1 default to 1.0, bondorder2 default to 2.0, etc. for backward compatibility and simplicity.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great call. I think that the bondorderN solution is exactly what we need here. This sidesteps potential issues with support for . characters in different representations.

If we wanted to maintain backward compatibility

This may not actually be possible at all. The Bonds and ProperTorsions section versions will need to be bumped for this update, since this adds a new keyword (bondorderN) that wasn't in the old section. (that is, if today's version of the OpenFF toolkit says that it supports Bonds section version 0.4, and the bondorderN keyword comes in, then an error will be raised. So the section version must not be 0.4 any more).

We explicitly forbid reading "serendipitously" valid OFFXML contents that have an unsupported version. This is because the version number can change the default values of optional attributes. So two nearly-identical OFFXML files that differ only by a section version could encode different physics.

But REVERSE compatibility isn't really a problem, because non-time travelers will be more interested in FORWARD compatibility. The current parameter handlers can recognize and handle a range of old section versions so we should be in good shape there. (that is, ProperTorsionHandler can be updated to read every ProperTorsions section version from 0.3 to 0.5)

So, this would lead to a spec bump of Bonds and ProperTorsions to version 0.5. I've made an Issue tag to indicate that this will require a section version bump.

have bondorder1 default to 1.0, bondorder2 default to 2.0, etc

I (begrudgingly) think this is a good idea. It's (begrudging) because implementing optional attributes is always a nightmare, especially when they relate to other optional attributes, and double especially for the forest of indexed, double indexed, and optional attributes that ProperTorsionHandler has to process correctly. But I think it's worth it for the user experience, and to have ProperTorsion elements in the OFFXML have a shorter line length.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the criticisms above are spot-on and the solution here seems like the best way to approach this. I'll work to update the proposal accordingly.

The only bit of context I'd like to add is that we haven't released any force fields with parameter interpolation, so it's possible this could be coordinated to avoid the need to shop an up-converter of existing files from 0.3 or 0.4 to 0.5. There would be a burden on internal users to update, but we that's easier to do than tweak data that's already slipped out to production.

@@ -524,6 +524,9 @@ This works even when barrier heights for more than two integer bond orders are s
In other words, a fractional bond order of 3.2 would yield an interpolated `k#` value determined by the interpolation line between ``k#_bondorder2`` and ``k#_bondorder3``.
A fractional bond order of .9 would yield an interpolated `k#` value determined by the interpolation line between ``k#_bondorder1`` and ``k#_bondorder2``.

The bond orders used here for interpolation between are all integers, however they do not
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Including the example from the OFF-EP here would be helpful.

their associated parameters. Work by the Open Force Field Initiative has suggested cases in which it
would be useful to have non-integer bond orders such that i.e. parameters are interpolated between
bond orders of 1.0 and 1.2 in a different way than they may be between bond orders of 1.2 and 2.0.
The current speification does not explicitly forbid non-integer bond orders, but the section
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The current speification does not explicitly forbid non-integer bond orders, but the section
The current specification does not explicitly forbid non-integer bond orders, but the section

<Bonds version="0.3" potential="harmonic" fractional_bondorder_method="AM1-Wiberg" fractional_bondorder_interpolation="linear">
<Bond
smirks="[#6X3:1]!#[#6X3:2]"
k_bondorder1="820.0*kilocalories_per_mole/angstrom**2"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great call. I think that the bondorderN solution is exactly what we need here. This sidesteps potential issues with support for . characters in different representations.

If we wanted to maintain backward compatibility

This may not actually be possible at all. The Bonds and ProperTorsions section versions will need to be bumped for this update, since this adds a new keyword (bondorderN) that wasn't in the old section. (that is, if today's version of the OpenFF toolkit says that it supports Bonds section version 0.4, and the bondorderN keyword comes in, then an error will be raised. So the section version must not be 0.4 any more).

We explicitly forbid reading "serendipitously" valid OFFXML contents that have an unsupported version. This is because the version number can change the default values of optional attributes. So two nearly-identical OFFXML files that differ only by a section version could encode different physics.

But REVERSE compatibility isn't really a problem, because non-time travelers will be more interested in FORWARD compatibility. The current parameter handlers can recognize and handle a range of old section versions so we should be in good shape there. (that is, ProperTorsionHandler can be updated to read every ProperTorsions section version from 0.3 to 0.5)

So, this would lead to a spec bump of Bonds and ProperTorsions to version 0.5. I've made an Issue tag to indicate that this will require a section version bump.

have bondorder1 default to 1.0, bondorder2 default to 2.0, etc

I (begrudgingly) think this is a good idea. It's (begrudging) because implementing optional attributes is always a nightmare, especially when they relate to other optional attributes, and double especially for the forest of indexed, double indexed, and optional attributes that ProperTorsionHandler has to process correctly. But I think it's worth it for the user experience, and to have ProperTorsion elements in the OFFXML have a shorter line length.

@mattwthompson
Copy link
Member Author

Thanks for all the feedback - I think this is heading in the right direction but it'll take a bit more care to get it into a state that is ready for another review. In particular, this idea won't immediately work so cleanly for torsions - mostly because the current kN_bondorderM approach squeezes the periodicity and bond order together in a way that could be confusing. Maybe kN_M is fine, I'll don't want to decide now.

@jchodera
Copy link
Member

In particular, this idea won't immediately work so cleanly for torsions - mostly because the current kN_bondorderM approach squeezes the periodicity and bond order together in a way that could be confusing. Maybe kN_M is fine, I'll don't want to decide now.

I don't understand this. What is kN_bondorderM and kN_M?

@mattwthompson
Copy link
Member Author

For interpolated (periodic) torsions, there are different force constants for each periodicity and interpolation point. Like in the

<ProperTorsions ... >
    <Proper ... k1_bondorder1="1.00*kilocalories_per_mole" k1_bondorder2="1.80*kilocalories_per_mole" idivf1="1.0"/>
    ...

It's a matter of picking the best variable name for encoding this. Above you suggested k_bondorder2 -> k2 for bonds, which doesn't work 1:1 as in torsions (k1_bondorder2 -> k1_2 would be confusing and somewhat ambiguous). k1_bondorder is probably better.

@mattwthompson
Copy link
Member Author

This doesn't seem to be so important after all, but it's all laid out here if somebody wants to do it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SMIRNOFF: Using non-integer bond orders in interpolation
5 participants