Table Of Contents

Previous topic

7.7. Fast QCP RMSD structure alignment — MDAnalysis.core.qcprot

Next topic

7.9. Helper functions — MDAnalysis.core.util

This Page

7.8. Constants and unit conversion — MDAnalysis.core.units

The base units of MDAnalysis are Angstrom for length (1 Angstrom = 0.1 nm = 10^-10 m) and ps (pico second) for time (1 ps = 10^-12 sec).

All conversions: the conversion factor f to a unit b’ for a quantity X (whose numeric value relative to the base unit b is stored in the program) is a quantity with unit b’/b. In the dictionaries below only the numeric value f(b->b’) is stored:

X/b' = f(b->b') * X/b

get_conversion_factor() returns the appropriate factor f(b->b’).

Conversion is done via the base units:

x is in u1: from u1 to b:  x'  = x  / factor[u1]
            from b  to u2: x'' = x' * factor[u2]
so f[u1,u2] = factor[u2]/factor[u1]

7.8.1. Conversions

density conversion factor. Base unit is A**-3:

n/x = n/A**3 * densityUnit_factor[x]

nm:

f = 1 A^-3/1 nm^-3 = 1/(10A)^-3 = 1/1000

Molar:

factor = 1 A**-3 / (N_Avogadro * (10**-9 dm)**-3)

relative to a density rho0 in g/cm^3:

M(H2O) = 18 g/mol   Molar mass of water

factor = 1/(1e-24 * N_Avogadro / M(H2O))

from rho/rho0 = n/(N_A * M**-1) / rho0 where [n] = 1/Volume, [rho] = mass/Volume

See also

Maybe we should simply use Quantities?

7.8.2. Functions

MDAnalysis.core.units.get_conversion_factor(unit_type, u1, u2)

generate the conversion factor u1 -> u2 by using the base unit as an intermediate

f[u1 -> u2] = factor[u2]/factor[u1]

Conversion of X (in u1) to X’ (in u2):

X’ = conversion_factor * X
MDAnalysis.core.units.convert(x, u1, u2)

Convert value in unit u1 to u2.

7.8.3. Data

MDAnalysis.core.units.lengthUnit_factor = {'A': 1.0, 'picometer': 100.0, 'Angstrom': 1.0, 'femtometer': 100000.0, 'nm': 0.1, 'pm': 100.0, 'nanometer': 0.1, 'fm': 100000.0, '\xc3\x85': 1.0, 'angstrom': 1.0}

The basic unit of length in MDAnalysis is the Angstrom. Conversion factors between the base unit and other lengthUnits x are stored. Conversions follow L/x = L/Angstrom * lengthUnit_factor[x]. x can be nm/nanometer or fm.

MDAnalysis.core.units.N_Avogadro = 6.02214179e+23

Avogadro’s constant in mol**-1,

MDAnalysis.core.units.water = {'MolarMass': 18.016, 'SPC': 0.985, 'TIP4P': 1.001, 'exp': 0.997, 'TIP3P': 1.002}
water density values ay 1179: T=298K, P=1atm [Jorgensen1998]
model g cm**-3
SPC 0.985(1)
TIP3P 1.002(1)
TIP4P 1.001(1)
exp 0.997

and molar mass 18.016 g mol**-1.

MDAnalysis.core.units.densityUnit_factor = {'Molar': 1660.5387831627258, 'water': 30.006285574182215, 'A^{-3}': 1.0, 'nm^{-3}': 1000.0, '\xc3\x85^{-3}': 1.0, 'nanometer^{-3}': 1000.0, 'SPC': 30.37184438320779, 'Angstrom^{-3}': 1.0, 'TIP4P': 29.88638033712255, 'TIP3P': 29.856553610239185}

The basic unit for densities is Angstroem**(-3), i.e. the volume per molecule in A**3. Especially for water it can be convenient to measure the density relative to bulk, and hence a number of values are pre-stored in water.

MDAnalysis.core.units.timeUnit_factor = {'ps': 1.0, 'second': 1e-12, 'fs': 1000.0, 'sec': 1e-12, 'picosecond': 1.0, 'femtosecond': 1000.0, 'AKMA': 20.45482949774598, 'ns': 0.001, 'nanosecond': 0.001, 's': 1e-12}

For time, the basic unit is ps; in particular CHARMM’s 1 AKMA time unit = 4.888821E-14 sec is supported.

MDAnalysis.core.units.speedUnit_factor = {'Angstrom/picosecond': 1.0, '\xc3\x85/ps': 1.0, 'm/s': 100.0, 'nm/ps': 0.1, 'nm/ns': 100.0, 'Angstrom/AKMA': 0.04888821, 'pm/ps': 100.0, 'angstrom/picosecond': 1.0, 'A/ps': 1.0, 'Angstrom/ps': 1.0, 'nanometer/picosecond': 0.1, 'nanometer/ps': 0.1}

For speed, the basic unit is Angstrom/ps.

MDAnalysis.core.units.chargeUnit_factor = {'Amber': 18.2223, 'C': 1.602176487e-19, 'e': 1.0, 'As': 1.602176487e-19}

Charge is measured in multiples of the electron charge e = 1.602176487 x 10**(-19) C.

MDAnalysis.core.units.conversion_factor = {'length': {'A': 1.0, 'picometer': 100.0, 'Angstrom': 1.0, 'femtometer': 100000.0, 'nm': 0.1, 'pm': 100.0, 'nanometer': 0.1, 'fm': 100000.0, '\xc3\x85': 1.0, 'angstrom': 1.0}, 'time': {'ps': 1.0, 'second': 1e-12, 'fs': 1000.0, 'sec': 1e-12, 'picosecond': 1.0, 'femtosecond': 1000.0, 'AKMA': 20.45482949774598, 'ns': 0.001, 'nanosecond': 0.001, 's': 1e-12}, 'speed': {'Angstrom/picosecond': 1.0, '\xc3\x85/ps': 1.0, 'm/s': 100.0, 'nm/ps': 0.1, 'nm/ns': 100.0, 'Angstrom/AKMA': 0.04888821, 'pm/ps': 100.0, 'angstrom/picosecond': 1.0, 'A/ps': 1.0, 'Angstrom/ps': 1.0, 'nanometer/picosecond': 0.1, 'nanometer/ps': 0.1}, 'charge': {'Amber': 18.2223, 'C': 1.602176487e-19, 'e': 1.0, 'As': 1.602176487e-19}, 'density': {'Molar': 1660.5387831627258, 'water': 30.006285574182215, 'A^{-3}': 1.0, 'nm^{-3}': 1000.0, '\xc3\x85^{-3}': 1.0, 'nanometer^{-3}': 1000.0, 'SPC': 30.37184438320779, 'Angstrom^{-3}': 1.0, 'TIP4P': 29.88638033712255, 'TIP3P': 29.856553610239185}}

conversion_factor is used by get_conversion_factor(): Note: any observable with a unit (i.e. one with an entry in the unit attribute) needs an entry in conversion_factor

MDAnalysis.core.units.unit_types = {'Molar': 'density', 'Angstrom/picosecond': 'speed', '\xc3\x85/ps': 'speed', 'm/s': 'speed', 'Angstrom^{-3}': 'density', '\xc3\x85': 'length', 'second': 'time', 'sec': 'time', 'Angstrom': 'length', 'nm/ns': 'speed', 'Angstrom/AKMA': 'speed', 'nanometer': 'length', 'pm/ps': 'speed', 'ps': 'time', 'angstrom/picosecond': 'speed', 'nm': 'length', 'nanometer^{-3}': 'density', 'A/ps': 'speed', 'nanosecond': 'time', 'As': 'charge', 'angstrom': 'length', 'AKMA': 'time', 'ns': 'time', 'pm': 'length', 'A': 'length', 'C': 'charge', 'fs': 'time', 'femtosecond': 'time', 'nm/ps': 'speed', 'TIP3P': 'density', 'water': 'density', 'A^{-3}': 'density', 'nm^{-3}': 'density', 'picosecond': 'time', 'fm': 'length', 'Amber': 'charge', 'nanometer/picosecond': 'speed', 'e': 'charge', 'TIP4P': 'density', 'Angstrom/ps': 'speed', 'SPC': 'density', 's': 'time', '\xc3\x85^{-3}': 'density', 'femtometer': 'length', 'nanometer/ps': 'speed', 'picometer': 'length'}

Generated lookup table (dict): returns the type of unit for a known input unit. Note: Any unit must be unique because this dict is used to guess the unit type.

7.8.4. References

[Jorgensen1998]
  1. Jorgensen, C. Jenson, J Comp Chem 19 (1998), 1179-1186