polymerist.unitutils

Physical constants, dimensional analysis, and unit conversion utilities

Submodules

Exceptions

MissingUnitsError

Common base class for all non-exit exceptions.

Functions

hasunits(→ bool)

Naive but effective way of checking for pint and openmm units

strip_units(→ Union[T, numpy.ndarray[Any]])

Sanitize coordinate tuples for cases which require unitless quantities

is_volume(→ bool)

Check whether a Unit or Quantity dimensionally corresponds to a volume

quantities_approx_equal(→ bool)

Check whether two Quantity objects with compatible dimensions

Package Contents

exception polymerist.unitutils.MissingUnitsError[source]

Bases: Exception

Common base class for all non-exit exceptions.

polymerist.unitutils.hasunits(obj: Any) bool[source]

Naive but effective way of checking for pint and openmm units

polymerist.unitutils.strip_units(coords: T | pint.Quantity | openmm.unit.Quantity) T | numpy.ndarray[Any][source]

Sanitize coordinate tuples for cases which require unitless quantities Specifically needed since OpenMM and pint each have their own Quantity and Units classes

polymerist.unitutils.is_volume(unitlike: Unit | Quantity) bool[source]

Check whether a Unit or Quantity dimensionally corresponds to a volume Accepts both OpenMM-style and Pint-style unit-like objects

polymerist.unitutils.quantities_approx_equal(quantity_expected: Quantity, quantity_actual: Quantity, rel_tol: float = 1e-08) bool[source]

Check whether two Quantity objects with compatible dimensions are equal to within some set relative error (default 1E-8)

Accepts both OpenMM-style and Pint-style quantity-like objects