Fourmilab Home Page

Specification and Representation of
Physical Units in Computer Systems

by John Walker
September 9th, 1990

 

Attached is a description of a potential patent application on the system of units used within AutoCAD Release 11. The concept of deriving a universal system of units from fundamental physical constants is not original. I first encountered the idea in an article in Analog in 1967, in which the author suggested a replacement for metric units based on physical constants.

The scope of this disclosure is therefore not the concept of the system of units (which probably isn't patentable in any case), but rather the application of such a system of units within a computer to enable expression of physical quantities in a form not tied to any particular standard-making organisation and thus internationally and culturally neutral.

If this disclosure represents a patentable invention, and Autodesk wishes to pursue obtaining a patent on it, it will be necessary to allocate some individual in the technical group who understands this invention and its implementation to aid in the preparation of the patent application. If the application spells out, as I suspect it will have to, the algorithm used to interpret unit specifications in the associated language, preparing the application will be extremely time-consuming. I have neither the time to devote to such a process, nor any interest in pursuing it myself. If Autodesk chooses to undertake it, I will provide an initial briefing to the people involved and such limited support as I can manage given the time available.

Background

Scientific and engineering computation usually involves numbers that represent physical quantities such as length, mass, electrical current, or temperature. Most existing computer programs operate in terms of a single set of units, such as metric units (metres, kilograms, etc.) or the English system of units (inches, pounds). A mechanism that allows computation to be done independently of the choice of a system of units and enables a computer to detect dimensional errors in computations (such as adding length to mass) is the subject of a separate patent application.

This disclosure involves the means by which a computer user specifies the units in which data are input to such a computer system or program, and the units in which the results of the computation will be displayed. In addition, the internal representation in which the computer stores dimensioned quantities is defined, in terms independent of any particular system of units. The mechanism is composed of the following parts:

Example

A physical quantity might be specified in the language as:

0.022480894 meter kilogram / second^2

This is a quantity of force, actually equivalent to the “pound” in the English system of units.

The database contains definitions that are used to translate this specification in the form:

*meter,m
-1,0,1,0,-1,4.1214856408e11,0
*kilogram,kg
0,0,0,0,1,1.0977481015e30,0
*second,sec
-2,0,1,0,-1,1.235590484e20,0

The translator processes the specification, retrieves the definitions of the units from the database, combines them using the rules of algebra and the means of computing with units described in the previous patent disclosure, and emits a definition of the unit in terms of physical constants in the factor, bias, and unit exponent form described in the previous disclosure.

The Language

Units are specified either as a simple name, or as an expression in terms of existing units.

In any case, you can specify a predefined unit such as “meter” or “kilogram” just by naming it. Many of the common units have standard abbreviations (specified on the definition line following a comma), and you may use the abbreviation if you prefer.

You can multiply units together simply by naming the units to be multiplied separated by spaces. Since the units database defines the dimensionless multiple and submultiple names, this means that if you want a unit of micro-inches that's not defined in the file, you can specify the unit by simply entering “micro inch”. You can also specify numeric constants, so you could have defined micro inches as “1e-6 inch” as well.

You can multiply dimensioned units as well as dimensionless constants. If you want volume reported in acre-feet (used to specify capacity of water reservoirs), just compose the unit as “acre foot”.

You can affix an exponent to any unit by following it with a caret and the constant integer exponent. For example, a board-foot is defined as 144 cubic inches, so you could use that unit of volume by entering “144 inch^3”. Since square and cubic measures are so frequently used, you can define synonym prefixes for exponents. The English language version of a unit definition file declares “square” and “cubic,” so we can also specify board-feet as “144 cubic inch”.

Operator precedence is exponentiation first, multiplication second, and division (see below) last.

You can divide by units or constants by separating the expression into a numerator and denominator delimited by a slash, “/”. Only one slash may appear in an expression and it has the lowest precedence: the numerator and denominator are evaluated, then divided to form the unit. As a simple example of division, you could express mass in troy ounces by specifying “kg/32.150737”. A more complicated definition would be that of a pound of force as “0.022480894 meter kilogram / second^2”.

The Database

The database in the AutoCAD implementation is stored as an ASCII text file. Any representation could be used, in practice, as long as it provides the ability to store the names, numbers, and expressions used to define the units in the database.

Each unit declaration consists of two consecutive lines the in the file. The first line begins with with an asterisk in the first column, and gives the name of the unit and, optionally, an abbreviation set off by a comma. The second line declares the unit's dimensionality and magnitude in terms of the five physical constants. The unit can be defined either directly in terms of the constants (in which case it is termed a fundamental unit declaration), or as an expression in the language, written in terms of other units and ultimately resolvable into fundamental unit declarations. Units declared by an expression are referred to as derived units.

Fundamental unit declarations

All units are defined in a neutral system of measurement derived from five fundamental constants of physics. This system is culture-, species-, and environment-neutral and, stipulating the correctness of the cosmological principle, equally valid and independently derivable throughout the universe.

The fundamental constants which underlie the system are:

c Velocity of light in vacuum
e Electron charge
h Planck's constant
me Electron rest mass
k Boltzmann's constant

A basic unit definition consists of the seven coefficients α–η of the equation:

I = E cα eβ hγ mδ kε ζ + η

where E is the value in the system of measurement being defined (the “external” value), and I (the “internal” value) is the quantity with that dimensionality derived from the product of the powers of fundamental constants specified by α through ε. ζ and η effect the conversion from external to internal units.

For example, let's examine the definition of the SI unit “kilogram”. This is a unit of mass, and our fundamental unit of mass is the mass of the electron, which is 9.109558×10−31 kg. Since only one fundamental constant is needed to define mass, the exponent coefficients are very simple: δ, the exponent for the mass of the electron, is 1 and all the rest are zero. Since we know that zero mass is the same in both system of units, we know that η is zero (it's rarely needed, but permits handling units like degrees Celsius and Fahrenheit where zero is offset from zero in natural units).

I = E cα eβ hγ mδ kε ζ + η
I = E c0 e0 h0 m1 k0 ζ + 0
I = E m1 ζ
1 = 9.109558×10−31 m ζ
ζ = 1/9.109558×10−31
ζ = 1.0977481015×1030

Therefore the coefficients defining the kilogram in terms of fundamental constants are:

α = 0
β = 0
γ = 0
δ = 1
ε = 0
ζ = 1.0977481015×1030
η = 0

The definition of this unit consists of just these coefficients separated by commas on the line following the name of the unit and optional abbreviation:

*kilogram,kg
0,0,0,0,1,1.0977481015e30,0

Now let's consider a more complicated case, the Celsius temperature scale. First we need to determine the exponents of the physical constants which yield a quantity with dimensions of temperature. Boltzmann's constant is 1.38×10−23 J K−1, so clearly we need an exponent of −1 on Boltzmann's constant to get temperature in the numerator. But that leaves us with an unwanted unit of energy in the denominator that we'll need to cancel out. Well, Planck's constant is 6.62×10−34 J sec, so if we use an exponent of 1 on it, we get rid of the Joules, but now we've got time in the numerator! The speed of light has dimensions of length over time, so if we divide our length unit by it, we'll get time. But we don't have a pure length unit either! No problem. The combination h/mc has the dimensions of length (and happens to be the Compton wavelength of the electron, by the way), so we use that to get rid of length. After a little fiddling, then, we discover that the correct exponents to obtain a unit with dimensions of temperature are:

α = 2
β = 0
γ = 0
δ = −1
ε = 1

Substituting these exponents into the general equation, we discover that the natural unit of temperature works out to be 5.930127668×109 °K. Since we know that the size of the degree is the same in both the Celsius and Kelvin scales, it follows that ζ is just the reciprocal of this number, 1.6863043358×10−10. Since zero degrees Celsius is not absolute zero, we'll need a nonzero η to translate the zero point. Knowing that 0 in both the Kelvin and natural scales corresponds to −273.15 Celsius, we compute this as follows:

I = E ζ + η
0 = −273.15 ζ + η
0 = −273.15 × 1.6863043358×10−10 + η
η = 273.15 × 1.6863043358×10−10
η = 4.6061402932×10−8

Consequently, our definition of degrees Celsius is:

*celsius,c
2,0,0,-1,1,1.6863043358e-10,4.6061402932e-8

Other fundamental units are defined by the same process. Once you know the following identities for the natural units derived from the physical constants, the rest of the process is simple:

c = 2.9979250× 108 M/sec
e = 1.6021917×10−19 Coulomb
h = 6.626196×10−34 J sec
k = 1.380622×10−23 J/°K
m = 9.109558×10−31 kg
 
Length = h/mc
Mass = m
Time = Length/c
Current = e/Time
Temperature = h/k Time
 
Length = 2.42631×10−12 M
Mass = 9.10956×10−31 kg
Time = 8.0933×10−21 sec
Current = 19.7965 Ampere
Temperature = 5.93013×109 °K

Derived unit declarations

You can declare units in terms of other units defined in the database. These declarations are called derived units are are written as expressions in the same language used to specify dimensioned quantities. The second line of a derived unit definition declares the unit as an expression in constants and other units as described above. The first character of this line must be an equal sign to identify the definition as an expression as opposed to a fundamental definition.

For additional examples of unit definitions, examine the sample database appended to this document.


;       AutoCAD unit definition file -- ACAD.UNT

;       Basic SI units

*meter(s),metre(s),m
-1,0,1,0,-1,4.1214856408e11,0
*kilogram(s),kg
0,0,0,1,0,1.0977481015e30,0
*second(s),sec
-2,0,1,0,-1,1.235590484e20,0
*ampere(s),amp(s)
2,1,-1,0,1,0.050513907838,0
*kelvin,k
2,0,0,-1,1,1.6863043358e-10,0
*candela,cd
4,0,-1,0,2,9.885226216e-8,0

;       Derived SI units

*celsius,centigrade,c
2,0,0,-1,1,1.6863043358e-10,4.6061402932e-8
*rankine
2,0,0,-1,1,9.3683574212e-11,0
*fahrenheit
2,0,0,-1,1,9.3683574212e-11,4.30635285578e-8
*gram(s),gm,g
=kg 0.001
*newton(s),n
=meter kilogram / second^2
*pascal,pa
=newton/meter^2
*joule(s)
=newton meter

;       Exponent synonyms

*square,sq
^2
*cubic,cu
^3

;       Units of time

*centur(y.ies)
=100 year
*day(s)
=86400 second
*decade(s)
=10 year
*fortnight(s)
=14 day
*hour(s),hr
=3600 second
*millenni(um.a)
=1000 year
*minute(s),min
=60 second
*sidereal_year(s)
=365.25636 day
*tropical_year(s)
=365.24220 day
*week(s),wk
=604800 second
*year(s),yr
=365 day

;       Units of length

*Angstrom(s)
=meter 1E-10
*astronomical_unit(s),au
=meter 149597870000
*bolt(s)
=meter 36.576
*cable(s)                     ; U.S. cable length
=meter 219.456
*caliber
=meter 0.000254
*centimeter(s),centimetre(s),cm
=meter 0.01
*chain(s)                     ; Gunther's chain length
=meter 20.1168
*cubit(s)
=meter 0.4572
*decimeter(s),decimetre(s),dm
=meter 0.1
*dekameter(s),dekametre(s),dam
=meter 10
*fathom(s),fath
=meter 1.8288
*f(oot.eet),ft,'
=meter 0.3048
*furlong(s),fur
=meter 201.168
*gigameter(s),gigametre(s)
=meter 1E9
*hand(s)
=meter 0.1016
*hectometer(s),hectometre(s),hm
=meter 100
*inch(es),in,"
=meter 2.54E-2
*kilometer(s),kilometre(s),km
=meter 1000
*league_nautical
=meter 5556
*league_statute
=meter 4828.032
*light_year(s)
=meter 9.46053E15
*link(s)                      ; Gunther's link length
=meter 0.201168
*micron(s)
=meter 1E-6
*mil(s)
=meter 2.54E-5
*mile_nautical,inm            ; International Nautical Mile
=meter 1852
*mile_statute,mile(s),mi
=meter 1609.344
*millimeter(s),millimetre(s),mm
=meter 0.001
*millimicron(s)
=meter 1E-9
*pace(s)
=meter 0.762
*palm(s)
=meter 0.0762
*parsec(s)
=meter 3.085677E16
*perch(es)
=meter 5.0292
*pica(s)
=meter 0.0042175176
*point(s)
=meter 0.0003514598
*rod(s),pole(s)
=meter 5.0292
*rope(s)
=meter 6.096
*skein(s)
=meter 109.728
*span(s)
=meter 0.2286
*survey_f(oot.eet)
=0.3048006096 meter
*yard(s),yd
=meter 0.9144

;       Units of area

*acre(s)
=4046.85642 meter^2
*are(s)
=100 meter^2
*barn(s)
=1.0E-28 meter^2
*centare(s)
=1 meter^2
*hectare(s)
=10000 meter^2
*rood(s)
=1011.7141 meter^2
*section(s)
=2589988.096 meter^2
*township(s)
=93239571.456 meter^2

;       Units of volume

*barrel(s),bbl                ; International Petroleum barrel
=0.1589873 meter^3
*board_f(oot.eet),fbm
=144 inch^3
*bushel(s),bu                 ; U.S. dry bushel
=0.03523907 meter^3
*centiliter(s),cl
=0.01 liter
*cord(s)
=3.6245734 meter^3
*cc
=1e-6 meter^3
*decistere(s)
=0.1 meter^3
*dekaliter(s),dal
=10 liter
*dekastere(s)
=10 meter^3
*dram(s)                      ; U.S. fluid dram
=3.6967162 cc
*dry_pint(s)
=0.551 liter
*dry_quart(s)
=1.101 liter
*firkin(s)
=34.06775 liter
*gallon(s),gal                ; U.S. fluid gallon
=0.0037854118 meter^3
*gill(s)
=118.29412 cc
*hectoliter(s)
=100 liter
*hogshead(s),hhd
=0.23848094 meter^3
*kilderkin(s)
=0.08182957 meter^3
*kiloliter(s)
=1.000028 meter^3
*liter(s)
=0.001 meter^3                ; Redefined from 0.001000028m^3 in 1964
*milliliter(s),ml
=0.001 liter
*minim(s)
=6.160979e-5 liter
*fluid_ounce(s)
=2.9573730e-5 meter^3
*peck(s)
=8.809521 liter
*pint(s),fluid_pint(s)
=0.4731632 liter
*pottle(s)
=2.272980 liter
*puncheon(s)
=0.31797510 meter^3
*quart(s),qt,fluid_quart(s)
=0.9463264 liter
*register_ton(s)
=2.8316847 meter^3
*seam(s)
=290.9414 liter
*stere(s)
=1 meter^3
*tun(s)
=252 gallon

;       Units of mass

*dalton(s)
=1.66053e-27 kg
*dyne(s)
=kg/980665
*grain(s)
=kg/15432.358
*hundredweight(s),cwt
=45.359337 kg
*long_ton(s)
=1016.0469088 kg
*ounce_weight,ounce(s),oz
=kg/35.273962
*ounce_troy
=kg/32.150737
*pennyweight(s),dwt,pwt
=kg/643.01493
*poundal(s)
=kg/70.931635
*pound(s),lb
=0.45359237 kg
*scruple(s)
=kg/771.61792
*slug(s)
=14.5939 kg
*stone
=14 pound
*ton(s)
=907.18474 kg
*tonn(e.es)
=1000 kg

;       Units of frequency

*hertz,hz
=1/second

;       Electromagnetic units

*coulomb(s)
=ampere second
*farad(s)
=coulomb/volt
*henr(y.ies)
=ohm second
*ohm(s)
=volt/ampere
*siemens
=1/ohm
*tesla(s)
=weber/meter^2
*volt(s),v
=watt/ampere
*watt(s),w
=joule/second
*weber(s)
=volt second

;       Circular measure

*circle(s)
0,0,0,0,0,1,0
*radian(s)
=circle/6.28318530717958648
*degree(s)
=circle/360
*grad(s)
=circle/400
*quadrant(s)
=circle/4

;       Solid measure

*sphere(s)
0,0,0,0,0,1,0
*hemisphere(s)
=sphere/2
*steradian(s)
=sphere/12.566371

;       Dimensionless prefixes

;          Multiples
*deca
0,0,0,0,0,10,0
*hecto
0,0,0,0,0,100,0
*kilo
0,0,0,0,0,1000,0
*mega
0,0,0,0,0,10e6,0
*giga
0,0,0,0,0,10e9,0
*tera
0,0,0,0,0,10e12,0
*peta
0,0,0,0,0,10e15,0
*exa
0,0,0,0,0,10e18,0

;          Fractions
*deci
0,0,0,0,0,0.1,0
*centi
0,0,0,0,0,0,0.01,0
*milli
0,0,0,0,0,0.001,0
*micro
0,0,0,0,0,1e-6,0
*nano
0,0,0,0,0,1e-9,0
*pico
0,0,0,0,0,1e-12,0
*femto
0,0,0,0,0,1e-15,0
*atto
0,0,0,0,0,1e-18,0

;       Reference:  CRC Handbook, 68th edition ('87–'88).

;       Dimensions of common units in terms of fundamental constants

;       Measurement             C   E   H   K   M          Notes

;       Length                 -1       1      -1
;       Mass                                    1
;       Time                   -2       1      -1          time / C
;       Current                 2   1  -1       1          E / time
;       Temperature             2           -1  1          H / (K time)
;       Luminous intensity      4      -1       2          Units of power over
;                                                          solid angle, a
;                                                          dimensionless value.