Units (software)
Units is a cross-platform computer program for conversion of units of quantities. It has a database of measurement units, including esoteric and historical units. This for instance allows conversion of velocities specified in furlongs per fortnight, and pressures specified in tons per acre. Output units are checked for consistency with the input, allowing verification of conversion of complex expressions.
The original units program has been a standard part of Unix since the early Bell Laboratories versions.[1]
UDUNITS is a similar utility program, except that it has an additional programming library interface and date conversion abilities. UDUNITS is considered the de facto program and library for variable unit conversion for netCDF files.[2]
Contents |
[edit] GNU units
The newer GNU free software version of units (or GNU Units) was written by Adrian Mariano. GNU units includes several extensions to the original version, including
- Exponents can be written with '
^' or '**'. - Exponents can be larger than 9 if written with '
^' or '**'. - Sums of units (e.g.,
btu + ft lbf) can be converted. - Units that measure reciprocal dimensions can be converted (e.g.,
Stomegohm). - Parentheses for grouping are supported. The original version allowed only one solidus ('
/'), which sometimes required rearrangement of complex expressions; the GNU version allows more natural expressions, such as in the example that follows. - Roots of units (e.g.,
sqrt((lbf/inch) / lb)can be computed. - Nonlinear units conversions (e.g., °F to °C) are supported.
- Functions such as sin, cos, and log are included.
The plain text database units.dat is a good reference in itself, as it is extensively commented and cites numerous sources.
[edit] Usage
Units will output the result of the conversion in two lines. Usually the first line (multiplication) is the desired result. The second line is the same conversion expressed as a division.
Units can also do math while converting, including several built in mathematical functions such as sin, cos, atan, log, exp, etc.
If you attempt to convert types of measurements that are incompatible units will print a conformability error message and display a reduced form of each measurement.
[edit] Examples
The examples that follow show results from GNU units version 1.88; GNU units versions 1.84c and earlier defined a furlong in terms of the U.S. survey foot rather than international foot, and will give slightly different results than the examples that involve furlongs.
[edit] Interactive mode
2526 units, 72 prefixes, 56 nonlinear units
You have: 10 furlongs
You want: miles
* 1.25
/ 0.8
You have: 1 gallon + 3 pints
You want: quarts
* 5.5
/ 0.18181818
You have: sqrt(miles^2)
Definition: 1609.344 m
You have: 21 btu + 6500 ft lbf
You want: btu
* 29.352939
/ 0.034068139
You have:
[edit] On the command line (non-interactive)
C:\>units "ten furlongs per fortnight" "kilometers per hour"
* 0.0059871429
/ 167.02458
% units cup ounces
conformability error
0.00023658824 m^3
0.028349523 kg
[edit] Complex units expressions
One form of the Darcy–Weisbach equation for fluid flow is
where ΔP is the pressure drop, ρ is the mass density, f is the (dimensionless) friction factor, L is the length of the pipe, Q is the volumetric flow rate, and d is the pipe diameter. It might be desirable to have the equation in the form
that would accept typical US units; the constant A1 could be determined manually using the unit-factor method, but it could be determined more quickly and easily using units:
$ units "(8/pi^2)(lbm/ft^3)ft(ft^3/s)^2(1/in^5)" psi
* 43.533969
/ 0.022970568
Crane Technical Paper No. 410,[3] Eq. 3-5, gives the multiplicative value as 43.5.
[edit] References
- ^ Bell Telephone Laboratories, Incorporated (1979). "Unix Seventh Edition Manual". Murray Hill, NJ: Alcatel-Lucent Bell Labs. http://plan9.bell-labs.com/7thEdMan/. Retrieved 2011-04-23. Online archive of the manual pages included with the Seventh Edition Unix distribution tapes.
- ^ As specified from several NetCDF conventions, e.g.:
- ^ Technical Paper No. 410, Flow of Fluids through Valves, Fittings, and Pipe. New York: Crane Co. 1985. http://www.flowoffluids.com/publications/crane-tp-410.aspx.

