Openff-toolkit: Where should simtk.unit.Quantities be enforced?

Created on 24 Oct 2018  路  4Comments  路  Source: openforcefield/openff-toolkit

I'm going ahead with the idea of using simtk.unit.Quantity's wherever applicable, but I don't want to go overboard. Could I get a yes/no on the following cases?
1) require that distances are in a distance unit (eg conformer positions, virtualsite definitions in Angstrom/nanometer)
2) require that angles specify an angle unit (virtualsite in_plane_angle definition in degrees/radians)
3) require units of charge for electrostatics (eg virtualsite charge_increments in electron charges)
4) require units for epsilon/rmin_half/sigma when defining VdW parameters in a VirtualSite (different units, might be overboard if there's just one convention)

Most helpful comment

I think we should definitely require users specify units of the correct dimension for any dimensioned quantities. This absolutely reduces critical and subtle failures.

Also, see the Mars Climate Orbiter.

All 4 comments

馃憤 to all of these. Many codes use different units for length, energy, and angle, so anytime you have any of these involved there is potential for confusion or a need to consult the docs. That means that item 4 is especially a point of confusion as it combines length and energy.

(If only I had a dollar back for every time I had to go poking around in documentation to find out what units I needed to specify some quantity in. Please, no more.)

I think we should definitely require users specify units of the correct dimension for any dimensioned quantities. This absolutely reduces critical and subtle failures.

Also, see the Mars Climate Orbiter.

Ha! Ok, that settles it. unit.Quantity wrapping for all.

One odd thing is that OpenMM insists on getting epsilon in kJ/mol [1]. The per mole part becomes part of the unit. This would prevent someone from defining it in terms of a per-particle quantity (eg... electron*volt). On one hand, it might be good to leave this as a reminder for folks to distinguish between per-particle and per-mole quantities. On the other, forcing it to be a per-particle quantity might be cumbersome. For now I'll play it safe and check input for strict compatibility with kcal/mole.

Any thoughts?

[1] http://docs.openmm.org/7.0.0/api-c++/generated/OpenMM.NonbondedForce.html

Unit type checks for all virtualsite parameters implemented in commit https://github.com/openforcefield/openforcefield/pull/119/commits/44cfcb8ac4c0dbb901172cf71387f2b21ab56ad8

Was this page helpful?
0 / 5 - 0 ratings