HTML automatically generated with rman
Table of Contents

Name

units - units conversion utility

Synopis

units from=from to=to [parameter=value ...]

Description

The units program converts quantities expression in various scales to their equivalents in other scales. The units program can only handle multiplicative (linear) scale changes. This means it cannot convert Centigrade to Fahrenheit, for example.

Parameters

The following parameters are recognized in any order if the keyword is also given:
from=unit_from.
Unit to convert from. No default.
to=unit_to
Unit to convert to. No default.
unit=unit_file
Units database file. Multiple files can be given, separated by commas. A search path ".:$NEMODAT" is employed, so a local file is always tried before a file in $NEMODAT. Default: units.lib.
show=mul|div
Option to select the multiplicative or it’s inverse factor you need to convert from Iunit_from to unit_to, i.e.
    unit_from = unit_to * mul
    unit_from = unit_to / div
Valid options are mul and div. You can also select to show both, although the mul is always shown first, irrespective of the order given. [Default: mul].
quiet=t|f
Be quiet in interactive mode? [Default: t] NOTE: interactive

mode not implemented

Examples

It takes about 977 km/s to make one kpc in 10^6 yr:
    % units kpc/Myr km/s 
    977.81311
or a bit more mondaine:
    % units meters feet
    3.2808399

You can also use constants in the units expressions. For example, if you need to know the length of something in multiples of 5 cm, but know it’s 3 feet, try

    % units "3*feet" "5*cm"
      18.288 
Note the usage of the (single or double) quotes to prevent the shell from interpreting the * meta character.

Powers of units can be specified using the ’^’ character as shown in the example, or by simple concatenation: ’cm3’ is equivalent to ’cm^3’. Multiplication of units can be specified by using spaces, a dash or an asterisk. Division of units is indicated by the slash (’/’). Note that multiplication has a higher precedence than division, so If the user enters incompatible unit types, the units program will print a message indicating that the units are not conformable and it will display the reduced form for each unit:

    % units ergs/hour "fathoms kg^2 / day"
    conformability error
            2.7777778e-11 kg m^2 / sec^3
            2.1166667e-05 kg^2 m / sec
Also note the use of double quotes in order for NEMO to read the unit_to in the second argument/keyword.

The conversion information is read from a units data file. The default file includes definitions for most familiar units, abbreviations and metric prefixes. Some constants of nature included are:

pi    ratio of circumference to diameter
c    speed of light
e    charge on an electron
g    acceleration of gravity
force    same as g
mole    Avogadro’s number
water    pressure per unit height of water
mercury    pressure per unit height of mercury
au    astronomical unit
’Pound’ is a unit of mass. Compound names are run together so ’poundforce’ is a unit of force. British units that differ from their US counterparts are prefixed with ’br’, and currency is prefixed with its country name: ’belgiumfranc’, ’britainpound’. When searching for a unit, if the specified string does not appear exactly as a unit name, then the units program will try to remove a trailing ’s’ or a trailing ’es’ and check again for a match.

All of these definitions can be read in the standard units file, or you can supply your own file. A unit is specified on a single line by giving its name and an equivalence. One should be careful to define new units in terms of old ones so that a reduction leads to the primitive units which are marked with ’!’ characters. The units program will not detect infinite loops that could be caused by careless unit definitions.

Prefixes are defined in the same was as standard units, but with a trailing dash at the end of the prefix name.


prefix    abbrev.    factor
yotta-    Y-    1e24
zetta-    Z-    1e21
exa-    E-    1e18
peta-    P-    1e15
tera-    T-    1e12
giga-    G-    1e9
mega-    M-    1e6
myria-        1e4
kilo-    k-    1e3
hecto-    h-    1e2
deka-    da-    1e1
deci-    d-    1e-1
centi-    c-    1e-2
milli-    m-    1e-3
micro-        1e-6
nano-        1e-9
pico-    p-    1e-12
femto-    f-    1e-15
atto-    a-    1e-18
zopto-    z-    1e-21
yocto-    y-    1e-24

G

The gravitational constant is often set to unity in N-body codes. However, for sake of completeness, here are a few common values of G in some other ’common’ unit systems, recalling that G*m/(r*v*v) is dimensionless:
  mass   length   velocity    G            1/G            time
     g       cm       cm/s    6.6732e-8    1.49853e+07      s      (cgs)
    kg        m        m/s    6.6732e-11   1.49853e+10      s      (SI)
     M     Rsol       km/s    1.90809e5                            (solar
tides)
     M       AU       km/s    886.8        1.128e-3        4.74yr  (planets)
     M       AU  29.8 km/s    1            1              0.159yr  (planets)
     M       AU               39.478                       1yr     (planets)

     M       pc       km/s    4.302e-3     2.32385e2       1e6.yr  (starcluster)
     M       kpc      km/s                 2.32385e5       1e9.yr
1e10.M    10.kpc  100.km/s                 2.32385         1e8.yr  (galaxy)
~2e4.M       kpc ~990.km/s    1            1               1e6.yr  (galaxy)
1e11.M    10.kpc ~97.8.km/s   4.497        0.22237         1e8.yr  (galaxy)
1e10.M     1.kpc     1.km/s   43007.1                              (GADGET)

Memorizable Conversions


1 pc    3.086e18 cm
1 AU    1.496e13 cm
1 radian    206265 arcsec
1 yr           3.156e7 sec
1 solarmass    1.988e33 g
1 km/s          1.023 pc per million year
1 arcsec/yr    4.74 km/s at 1 pc
1 arcsec        4.848 pc/Mpc_distance
See also constants(5NEMO) for some other constants.

Bugs

The effect of including a ’/’ in a prefix is surprising.

Exponents entered by the user can be only one digit.

The user must use | to indicate division of numbers and / to indicate division of symbols. This distinction should not be necessary.

The program contains various arbitrary limits on the length of the units converted and on the length of the data file.

See Also

expr(1) , units(5NEMO) , nemoinp(1NEMO)

NIST: http://physics.nist.gov/cuu/Constants/index.html

NIST: http://physics.nist.gov/PhysRefData/contents.html

FRINK: http://futureboy.homeip.net/frinkdocs/

units calculator: http://www.astro.wisc.edu/~dolan/constants/calc.html

Granot, Scaling relations between numerical simulations and physical systems they representP, http://arxiv.org/pdf/1111.6865v1

https://en.wikipedia.org/wiki/N-body_units

Files


$NEMODAT/units.lib - the standard units library 
/usr/lib/units     - original units library from units(1)
Sadly, the modified units.c with the NEMO interface has been lost

Author

Adrian Mariano (adrian@u.washington.edu or mariano@geom.umn.edu)

Update History


14-jul-93    V1.0 Original version    AM
21-jul-93    V2.0 Conversion to nemo    PJT
8-aug-93    V2.1 cleanup, reset defaults, switch key order    PJT


Table of Contents