Units and Conversions

The units used by narupatools are the same as used for Narupa and OpenMM:

Units of narupatools

Quantity

Unit

SI Unit

Length

Nanometers (\(\text{nm}\))

\(10^{-9} \text{m}\)

Time

Picoseconds (\(\text{ps}\))

\(10^{-12} \text{s}\)

Mass

Dalton (\(\text{Da}\))

\(1.661 \times 10^{-27} \text{kg}\)

Charge

Elementary charge (\(\text{e}\))

\(1.602 \times 10^{-19} \text{C}\)

Temperature

Kelvin (\(\text{K}\))

Angle

Radians (\(\text{rad}\))

Energy

Kilojoules per mole (\(\text{kJ} \text{mol}^{-1}\))

\(6.022 \times 10^{-27} \text{J}\)

Force

Kilojoules per mole per nanometer (\(\text{kJ} \text{mol}^{-1} \text{nm}^{-1}\))

Velocity

Nanometers per picosecond (\(\text{nm} \text{ps}^{-1}\))

Acceleration

Nanometers per picosecond squared (\(\text{nm} \text{ps}^{-2}\))

These units are consistent, in that the units of mass times acceleration are equal to the units of force. This is not true in certain other packages such as MDAnalysis.

Unit conversions are normally done by either having defined constants (such as NM_TO_A to convert nanometers to angstroms), or through wrapping quantities like OpenMM’s Quantity.

This package provides useful methods for converting between the various unit systems, without having to know exactly what units they use and hence which constants to use. Each package has a UnitSystem that stores the units used for each quantity:

  • Narupa/narupatools has the unit system UnitsNarupa. This uses the unit system as described above.

  • OpenMM has the unit system UnitsOpenMM. This is the same unit system as Narupa.

  • ASE has the unit system UnitsASE. The unit system of ASE is described here.

  • MDAnalysis has the unit system UnitsMDAnalysis. It is similar to Narupa/OpenMM, except it uses degrees for angles and angstrom for length.

  • MDTraj has the unit system UnitsMDTraj. It is similar to Narupa/OpenMM, except it uses degrees for angles.

  • LAMMPS actually has several unit systems (as described here. Each of these exists as a separate unit system (such as UnitsLAMMPSNano), but there is also a function narupatools.lammps.get_unit_system(str)() that converts the LAMMPS name such as ‘nano’ into the corresponding unit system.

Each of these are instances of a UnitSystem. A unit system has attributes for all the main quantities that might need to be computed, such as force or length. The value returned by these will be the value this quantity takes expressed in standard Narupa units. For example, as MDAnalysis uses angstroms, UnitsMDAnalysis.length has a value of 0.1.

Conversions between these are done by creating a unit system conversion using the >> operator:

ASEToNarupa = UnitsASE >> UnitsNarupa

positions_narupa = atoms.get_positions() * ASEToNarupa.length

This object acts in a similar way to the unit system, except now properties such as .length would give the conversion factor from lengths in ASE units to lengths in Narupa units.

There are also units defined in narupatools.core.units such as electronvolt. These units can be multiplied, divided and exponentiated together to get another unit. When multiplied on the left by a float, they represent that value in this units, expressed in standard Narupa units. For example:

from narupatools.core.units import angstrom

value_nm = 2.42 * angstrom

Units also override the >> operator and hence can be used to get conversion factors in a pythonic way:

from narupatools.core.units import joule, electronvolt

joules_to_electronvolts = joule >> electronvolt