to_openmm
- openff.units.openmm.to_openmm(quantity: Quantity) openmm_unit.Quantity [source]
Convert an OpenFF
Quantity
to an OpenMMQuantity
openmm.unit.quantity.Quantity
from OpenMM andopenff.units.Quantity
from this package both represent a numerical value with units. The units available in the two packages differ; when a unit is missing from the target package, the resulting quantity will be in base units (kg/m/s/A/K/mole), which are shared between both packages. This may cause the resulting value to be slightly different to the input due to the limited precision of floating point numbers.Examples
>>> from openff.units import unit >>> from openff.units.openmm import to_openmm >>> from openmm import unit as openmm_unit >>> length = unit.Quantity(9.0, unit.angstrom) >>> to_openmm(length) Quantity(value=9.0, unit=angstrom) >>> assert isinstance(to_openmm(length), openmm_unit.Quantity)