9/28/98 DRAFT -- DO NOT REDISTRIBUTE!

The SI Library of Unit-Based Computation

Walter E. Brown, Ph.D.
Fermi National Accelerator Laboratory
Batavia, IL 60510-0500, USA

Copyright © 1998 by Walter E. Brown. All rights reserved. Other notices.

Contents


Abstract

We describe the general requirements, design, and usage of a C++ library based on the recognized international standard (SI) for describing measurable quantities and their units.

In their introductory text, Halliday and Resnick teach physicists to "... check the dimensions of all the equations you use." However, inspection of code samples reveals that scientific programmers typically make heavy use of a programming language's native numeric data types, thus obscuring the diverse intentions (e.g., distances, masses, energies, momenta, etc.) that any such purely numeric value could represent.

While limitations in programming language expressiveness and compiler technology have historically made such efforts difficult, the present project provides, in a modern programming language, a convenient means of expressing, computing with, and displaying numeric values with attached units. The fundamental requirements, (1) to apply compile-time type-checking while (2) avoiding time and space overhead at run-time, have been met. Thus, the Library enables automated (compile-time) checking of the dimensions of the numeric values within a computer program, and so provides the well-known benefits of type-safety to a new category of computing contexts.

In particular, this SI Library provides data types corresponding to all the base dimensions specified by SI. It also provides a mechanism to generate additional data types to describe and represent all derived dimensions in accordance with SI's provisions. Thus, for example, an object resulting from the product of two Length objects is automatically of type Area.

All the base and composite units specified by SI are provided as well, as are forms of the mandated prefixes for describing multiples and sub-multiples of the units. A significant number of additional standard values (any of which may be used as units), are also furnished within the Library. As additional features, the Library permits user specification, at compile time, of data representation, calibration, and models.

The following two lines of code suffice to access the Library's full capabilities:

    #include "SIunits/stdModel.h"
    using namespace si;    // optional

The Library itself is built from a relatively small amount of source code. This has been accomplished via extensive use of contemporary C++ technology, including namespaces and templates. Moreover, the byte-size of any object created via this Library is identical to the byte-size of an object of the native type having the identical data representation.


Introduction

  • Units-checking and type-safety

    Scientific work commonly deals with numbers that represent amounts of physical dimensions. Scientists are therefore trained, as a matter of routine, to be very careful with these numbers' units, lest incompatible values be accidentally combined in calculation or lest incorrect units be ascribed to the outcome. As Halliday and Resnick (pp. 35-6) exhort:

    In modern digital computation, the analogous concept is known as static type-checking. This concept lies at the core of such object-oriented programming languages as C++, and yields among the most valuable benefits of such software methodology. To demonstrate the analogy's accuracy, we paraphrase Halliday and Resnick above:

    As summarized by Fagan (pp. ii, 2), static typing provides:

    Fagan further notes that "simple conceptual errors" often manifest as type errors, that these are detectable by type-checking software (such as a compiler) used to ensure "... the type documentation is consistent," and (citing Gannon's study) that "[e]xperimental results estimate the number of errors due to detectable [sic] type faults as something between 30% and 80% of all program errors." The importance of type-checking to successful computing is validated by the substantial body of computing research devoted to the topic. For these and related reasons, programmers have long been taught to employ and rely on type-checking.

    Starting circa 1957, early high-level programming languages such as Fortran (and, later, C) followed the model of machine and assembly languages in allowing a programmer access to only a very few data types of general utility and applicability. Some twelve years later, such programming languages as Simula 67 and Pascal enabled use of data abstraction methodology by augmenting their native data types with relatively simple facilities for programmer-defined data types. According to Stroustrup, what we know as C++ classes evolved around 1980, while parameterized classes (now known as templates) provided even more powerful expressive capability ("parametric polymorphism") beginning around 1988.

    Programmers are thus now able to use all these expressive capabilities to design data types and families of data types tailored to the problem domain at hand, and to apply such types conveniently and routinely. Given the recent official international C++ standard, and given modern compiler technology (such as that available from Kuck and Associates) to support the bulk of this standard, we clearly have both ample motivation and ample technology to embrace type-safe object-oriented techniques in all contemporary applications of computer programming.

  • Prior work

    There have been several earlier efforts to attain these benefits. Perhaps the most useful to scientific programmers is currently found in the Units subdirectory of the CLHEP library. In their latest incarnations (originally authored by Maire and most recently modified by Tcherniaev in response to criticism by Lasiuk and Ullrich, among others), two files, PhysicalConstants.h and SystemOfUnits.h, define symbols for those units and important constants that are in common use by the high-energy physics community.

    The use of these and similar symbols provides, of course, an important boost to code readability and correctness. However, CLHEP's Units files provide neither symbols nor mechanisms to express the concepts of the various intended dimensions to which these symbols belong. Ultimately, all symbols are of type HepDouble, which is usually a synonym for the native C++ double data type. Only in a relativistic model where the speed of light is one should it be possible to add meters to seconds; it is otherwise highly unlikely to be a meaningful expression, and therefore highly likely to reflect a conceptual and attendant computational error.

    Oliver has proposed a different approach. While his outline appears to provide the benefits of type-safety, his main objective seems to concentrate on "Metric and English Units conversion/formatting" aspects. There is no mention of arithmetic in his sample code; indeed, he writes that "[he has] not yet solved the problem of multiplying/dividing mixed units."

    Outside the realm of programming libraries, Converter Pro and similar software products and projects have dealt with the problems of converting values among units of like dimension. Such software is only of tangential interest to the present effort, for they do not address issues of general-purpose programming. They are, in effect, merely special-purpose calculators.

    Finally, and perhaps most interesting, Wolfram's Mathematica system of mathematical computation supports symbolic tags (pp. 64, 538) and provides sufficient expressive power to employ such tags as unit markers during programmed computations. Tags can be attached to quantities and such tagged quantities can be combined in expressions. Via supplied databases, tagged values can be explicitly converted to yield equivalent values with different attached symbols.

    However, from the limited available documentation on this subject, it appears that implicit conversion (e.g., 1 foot + 1 inch) is not supported. We infer from this that Mathematica does not support expression of the general concept of a dimension of measurement (e.g., length). Further, the software's furnished databases seem to support only a single model; no database conversions were found to allow a relativist, for example, to write code that adds distance and time units.

  • Current programming practice

    Alas, in computer programming as practiced today, despite contemporary software technology, the standard of care recommended above seems only rarely applied to numeric quantities. Perhaps this prevailing attitude toward numeric computing is a lingering relic of the Fortran programming era's limitations; regardless, informal inspection of contemporary code samples revealed that programmers continue to make heavy use of a language's native numeric types (e.g., double) to the exclusion of customized numeric types (e.g., Velocity). A search of representative on-line archives did not even find any queries on the subject, suggesting little or no interest in, or knowledge of, alternatives.

    Given prior software art, this finding is not surprising. However, such overly-general practice is a common source of errors, for it fails to distinguish (and it even obscures!) the diverse intentions (e.g., distances, masses, energies, momenta, etc.) that any such purely numeric value can represent.

    Were such intentions routinely expressed in our computer programs, application of contemporary compiler technology would routinely provide us the benefits of type-safety in our numeric computations as a by-product of the translation process. This benefit is consistent with the unit-based approach so strongly advised by Halliday and Resnick, among many others.

  • Scope of current project

    Given (1) recommended unit-based practices of long standing, (2) the demonstrated utility of computer-based type-checking, (3) currently-available programming language and compiler technologies, yet (4) current deplorable practices in numeric computation, we set out to develop a software subsystem to provide a convenient means of expressing, computing with, and displaying numeric values with attached units, thus attaining the well-known benefits of type safety. An additional requirement of this project was to ensure strict compile-time type-checking without run-time overhead (i.e., at no run-time cost in time or in space).

    More specifically, we sought

    1. the application of contemporary software technology to numeric physical concepts,
    2. convenience of expression in such application,
    3. general utility rooted in existing standards,
    4. use of nomenclature from our problem domain, and
    5. no attendant performance penalties!

    The present project, known as The SI Library of Unit-based Computation, has succeeded in addressing these requirements. The resulting software module (known hereinafter as the SI Library or, simply, the Library) meets (and, in many respects, greatly exceeds!) all its goals and is intended for contribution (for non-commercial use) to the FPCLTF ("Zoom") project library at Fermilab.


    Underpinnings and Basic Features

  • International Standard of Units

    Le Système Internationale d'Unités (SI) is the recognized international standard for describing measurable quantities and their units. SI specifies seven mutually independent base quantities (dimensions): length, mass, time, electric current, thermodynamic temperature, amount of substance, and luminous intensity. The base units for describing amounts of these are specified, respectively, as the meter, kilogram, second, ampere, kelvin, mole, and candela.

    In addition, SI describes a consistent system for expressing new dimensions (e.g., energy) in terms of the seven base dimensions. In particular, it includes a list of 21 such derived dimensions whose amounts are described in specially-named composites (e.g., joule) of the base units. Finally, SI provides a list of prefixes for forming units' decimal multiples and sub-multiples.

  • Library basics

    In its most basic form, The SI Library of Unit-based Computation provides, in the form of data types, all the base dimensions specified by SI. Further, it provides the ability to declare additional data types to represent derived dimensions, also as specified.

    For programming convenience, a very significant number of derived dimensions have been included in the Library. In particular, virtually all the dimensions described by Horvath and by Pennycuick are provided. (See the "Tables of Predeclared Types" below for details.) A programmer is free to use, ignore, or add to these as may be convenient.

    Similarly, all the base and composite units specified by SI are provided in the Library, as are forms of the SI-mandated prefixes. Finally, an extensive collection of diverse units from published sources (including Horvath's, Pennycuick's, and the Particle Data Group's publications, as well as the CLHEP Units files) have also been included in the module. These encompass traditional MKS, CGS, UK, and US units, as well as a significant collection of constants of nature. Further, many units not in common use have also been provided in order to demonstrate both the diversity and the flexibility that the Library enables.

    As before, the programmer may use, ignore, or extend this list of units. We note that any amount may be used as a unit for a quantity of appropriate type; thus, both traditional units and standard values are combined in the "Tables of Predefined Units, Prefixes, and Constants" below.

    All the necessary infrastructure to take advantage of the SI Library is made available to a user program in the form of header files; in simplest form, the programmer merely inserts the following:

        #include "SIunits/stdModel.h"
        using namespace si;    // optional
    

    All the data types (technically, classes), units, and other values provided by the SI Library are thereby made available for subsequent use. However, all the Library's identifiers are declared within a C++ namespace so as to avoid introducing extraneous symbols; in consequence, one or more using statements are also required.

    The mechanisms for accessing and employing the Library's symbols are illustrated in the next section. Note that, by convention, most identifiers beginning with a capital letter represent data types. a very few such are, however, conventional names for standard constants (e.g., N_A for Avogadro's number, as shown in the Particle Data Book).


    Tutorial Examples

  • Instantiating and initializing

    We first illustrate the fundamentals of instantiating SI Library objects in connection with SI's basic Length dimension. Note that, in the absence of any explicit units, the appropriate base unit (or combination of base units) will be assumed. Further note that any mismatch between units and dimensions will produce a compile-time error.

        // -------------------------------------------------------
        //
        // Example 1: fundamentals of instantiation/initialization
        //
        // -------------------------------------------------------
    
        #include "SIunits/stdModel.h"
        using namespace si;       // make most si:: symbols available
        using namespace si::abbreviations;
    
        int main()  {
    
          // Successful instantiations:
          //
          Length d;               // initialized to 0 meters by default
          Length d2( 2.5 );       // 2.5 meters; same as 2.5 * m
          Length d3( 1.2 * cm );  // 1.2 centimeters; recorded as .012 * m
          Length d4( 5 * d3 );    // equivalent to 6.0 centimeters
          Length d5( 1.23 * pico_ * meter ); // 1.23e-12 * m
          Length d6( d2 + d3 );   // all dimensions match
    
          // Bad instantiation attempts; all detected at compile-time:
          //
          Length d7( d2 * d3 );   // oops: an Area can't initialize a Length
          Length d8 = 3.5;        // oops: 3.5 is not a Length
          Length d9;              // so far so good, ...
            d9 = 3.5;             // ... oops: 3.5 is still not a Length
    
          return 0;
    
        }  // main()
    

  • Computing and output

    We next illustrate some additional computation and output with Length and Length-related dimensions. Note in particular that the units in which values are displayed may be changed dynamically at will; however, no such change affects the internal representation of the value.

        // ----------------------------------
        //
        // Example 2:  computation and output
        //
        // ----------------------------------
    
        #include "SIunits/stdModel.h"
        using namespace si;               // get most si:: symbols
        using namespace si::abbreviations;
    
        #include <iostream>
        using namespace std;              // get all std:: symbols
    
        int main()  {
    
          // Display with default labels:
          //
          cout << inch << endl;           // display "0.0254 m"
    
          // Prefer centimeter labels from now on:
          //
          Length::showAs( cm, "cm" );     // set default display units
          cout << inch << endl;           // display "2.54 cm"
    
          // Compute/display:
          //
          Length len( 2*cm );
          Width  wid( 3*cm );             // Width is a synonym for Length
          Area   a( len * wid );
          cout << a << endl;              // display "6 cm^2"
    
          // Prefer to label Area in square meters:
          //
          Area::showAs( m*m, "m2" );      // set default display units
          cout << a << endl;              // display "0.0006 m2"
          cout << a*4 << endl;            // display "0.0024 m2"
    
          // But a volume reverts:
          //
          cout << a * 4*cm << endl;       // display "24 cm^3"
    
          return 0;
    
        }  // main()
    

  • Roots and powers

    We next demonstrate some of the additional available functionality, primarily involving roots and powers of SI units. Only constant integral powers and roots are directly supported. Additionally, the dimensions involved must be appropriate to the operation. Thus, the cube root of a Volume's value will yield a value of type Length; however, the cube root of an Area is deemed meaningless and will prevent compilation. (If there is sufficient demand, a future enhancement to the Library may remove these limitations in favor of constant rational powers and roots.)

        // ----------------------------
        //
        // Example 3:  powers and roots
        //
        // ----------------------------
    
        #include "SIunits/stdModel.h"
        using namespace si;                      // get most si:: symbols
        using namespace si::abbreviations;
    
        #include <iostream>
        using namespace std;                     // get all std:: symbols
    
        int main()  {
    
          Length::showAs( cm, "cm" );            // set default display units
    
          Length    edge( 2*cm );
          cout << Nth<3>::pow( edge ) << endl;   // display "8 cm^3"
    
          Volume    cube( 27*meter );
          cout << Nth<3>::root( cube ) << endl;  // display "300 cm"
    
          Radius    r( 2*in );                   // Radius is Length
          Perimeter p( 2 * pi * r );             // Perimeter is Length
          Area      c( pi * sqr(r) );            // a square Radius is an Area
          Diameter  d( sqrt(c/ pi) );            // sqrt of an Area is OK
          Length    huh( Nth<3>::root(c) );      // but cube root is not
    
          return 0;
    
        }  // main()
    


    Other Features

  • Choice of data representation

    By default, the Library employs the C++ native double data type as its underlying representation. Recognizing, however, that different programming projects may require different underlying data representations (e.g., float, long double, complex<float>, etc.), C++'s template mechanism was used throughout this Library's implementation. This allows a knowledgeable programmer to specify the data representation desired. The memory requirement for each object of an si type is exactly the same memory amount that would be required for an object of the underlying native type.

    A member function, pure(), is available to provide an SI Library object's value as the equivalent value of the underlying type; a second member function, measuredIn(), yields an SI Library object's value in multiples of a second (type-compatible) SI Library object's value. Use of these functions should, however, seldom be necessary.

  • No run-time overhead

    Because all type-checking is handled at compile-time and because of heavy use of inlining, there is no run-time computational overhead beyond the time taken for the necessary arithmetic. Thus, use of the SI Library incurs no performance penalty over computation on the native type.

  • Choice of calibration

    Because different users work with radically different magnitudes of values, the SI Library allows for certain user calibration. By default, each of the seven base units (meter, kilogram, second, etc.) is calibrated to a value of 1. However, for users who customarily work, say, in microns and nanoseconds, it is possible to calibrate the Library to treat these units as the base units instead. Such calibration, however, must be taken into account at the time the Library is built; dynamic recalibration is neither currently possible nor envisioned as a future enhancement of the Library.

  • Choice of model

    Finally, different programming projects may use different models of the universe. For example, to simplify certain computations, high-energy physics calculations often assume the speed of light to be 1. Such assumptions are also possible within the SI Library, and all consequences of such assumptions (e.g., the merging of the Length and Time dimensions) can be accurately modeled.

    The Library is supplied with five models; these are known, respectively, as the standard, relativistic, high-energy physics, quantum, and natural models. An application program selects the desired model via an #include "..." directive; details are provided in the "Table of Predefined World Views" below. A programmer pays no price for the availability of multiple models; only the code associated with the chosen model need be linked with application code. Additional models may, of course, be added to the Library by a knowledgeable programmer.

  • The World View

    As described above, the SI Library may be tailored to a programmer's preferences as to:

    These aspects are encompassed by a templated class, wv, known as the world view. While multiple world views may coexist within the Library, only one may be in use within a single program. Extending the Library with additional dimensions (types), constants, units, and world views is discussed below. Such extensions will smoothly coexist with existing Library features.

  • Compatibility

    In the main, the names chosen for use in the SI Library's repository of constants and units are identical to the comparable names in CLHEP's Units files. (Many of the Library's names, however, are absent from CLHEP, and are adapted from other sources, such as Mathematica.) To this extent, therefore, the SI Library is name-compatible with this aspect of CLHEP, thus easing a transition.

    The SI Library is not, however, strictly type-compatible with CLHEP. Because the unique feature of the SI Library is its type-safety, and because software using the SI Library will, by definition, be more type-conscious than other software, the two can not be directly combined.

    However, it is possible for SI-aware software to call routines from another library such as CLHEP. This is accomplished via two features of the SI Library. First, the member functions pure() and measuredIn(), described earlier, can be used to pass a numeric parameter (by value or by constant reference) to a non-SI function. Second, a numeric result returned by a non-SI function can be given the appropriate type by application of the type's constructor.


    Extensibility

  • More constants

    To instantiate new constants in an application program, statements such as shown in the following examples are used:

      const Time       solarDay     ( 24 * hour );
      const Time       sideralSecond( 0.99726956 * second );
      const SolidAngle squareDegree ( 3.046174e-4 * steradian );
    

    Note that these examples apply the usual C++ syntax for defining any object, constant or not, giving the object's type, its name, and its initial value. A constant object is distinguished only by the presence of the const keyword.

    To augment the Library with a new constant of interest, or to update a value of an existing constant, it is necessary to edit a single data file. Provide, for each new constant, its type, name, abbreviation (if any), and value. In particular, the file consts.dat is the Library's repository of such values; the interested reader is advised to inspect this file to learn the appropriate format. It will be necessary to rebuild the Library in order that the changes take effect.

  • More units

    Since any constant may function as a unit of measurement (for the corresponding dimension), the instructions in the previous sections serve equally well for augmenting the Library with new units as for augmenting with new constants.

  • More dimensions

    This section is largely unnecessary, as the Library already provides for all possible dimensions. In particular, as previously noted, all base dimensions mandated by SI are explicitly present. Further, all the SI derived dimensions are implicitly present in the Library in the form of code for their instantiation as needed.

    Technically, all dimensions have names of the form Dim<...>. In addition, also as previously described, a generous number of these dimensions have alternate names that are both more common and more convenient to use. These names are provided via the C++ typedef mechanism; this mechanism may also be used if any additional alternate names are desired. The interested reader is advised to inspect the Library file dims.dat to learn the appropriate format. If any changes are made to this file, it will be necessary to rebuild the Library in order that such changes take effect.

  • More world views

    As described above, a world view encompasses a desired data representation, model, and calibration. The information constituting a world view is currently spread among several Library files; as a result, augmenting the SI Library with a new world view is a meticulous process. However, once completed and built, a new or adapted world view is made available to future users indefinitely.

    Of the information provided by a world view, it is simplest to adjust the data representation, for it is merely a parameter to the world view template. The calibration is next easiest to change; but it involves updating a program (calibrate) that calculates the desired values as part of the build process. Most intensive in effort (because it requires the most planning) is to provide a new model.

    A short paper written by Fischler describes his methodology and its application to the specification of the Library's non-standard models. While his note provides considerable guidance in undertaking a new model, it may also be possible to create a new world view based on an existing one. Accordingly, the interested reader is advised to inspect wv.h, calibrate.cc, and one or more of the model-specific header and implementation files for appropriate examples.


    Caveats and Future Work

  • Naming

    Due to historical accident, several units used in measuring diverse dimensions share identical or similar names and/or abbreviations. For example, rad is the common abbreviation for a radian while, at the same time, a rad is an accepted unit of measure of specific energy (having been shortened from radiation dose). Similarly, a gal stands for a gallon, while a Gal abbreviates a Galileo.

    As a related problem, some units (e.g., calorie) have several accepted values, depending on their context (e.g., the international calorie, the mean calorie, the thermochemical calorie, etc.). This is true even though they share a common dimension of measurement (e.g., Energy). Similarly, such physical constants as the speed of sound have several values depending on both the medium (air, water, etc.) and the medium's temperature. For the sake of completeness, let us note that there are also historical variants of many quantities, although these can likely be ignored for most current purposes.

    While not technically within the domain of this Library, these problems are exacerbated in that the Library attempts to provide as comprehensive as possible a collection of units and physical constants. Accordingly, some policies should be formulated to govern the inclusion and exclusion of such overlapping unit names and values.

    As a starting point toward such standardization, we note that Lasiuk and Thomas have mandated the exclusion of all units' abbreviations from their STAR project's source code. Further, this policy has, as of this writing, been integrated into the pre-release of the CLHEP v1.3 Units files. However, others do find that many useful constants (e.g., c [the speed of light]) are commonly used as units in their abbreviated notations. Clearly, this issue is in need of further discussion to reach final consensus. In the interim, we have opted to put abbreviations into a sub-namespace.

  • Input

    User input of unit-based values has not yet been addressed. For example, such seemingly-innocent code as:

        Distance d
        cin >> d;
    
    needs to cope with input in the following forms, illustrating some of the notational challenges and the corresponding issues yet to be resolved:




    7.5 Implied units ok?

    7.5ft Concatenated units ok?

    7.5 ft How much whitespace?

    7.5foot Abbreviated units required?

    7.5feet Plurals? Other alternate notations?

    7.5' Feet or minutes?

    7ft6in Concatenated subunit or two inputs?

    7ft 6in One input? Two inputs?

    Related issues include input notations for, say, units of Area, units of Velocity, and other composite units. We may also consider providing all I/O via the standard C++ library iostream facet mechanisms.

  • Unit conversions

    At present, the Library assumes that all unit conversions between values of like types can be carried out via simple multiplication. While this assumption does hold in the overwhelming majority of cases, it is not universally true. For example, the conversions between degrees Kelvin and degrees Celsius require addition, not multiplication. Similarly, the conversions between degrees Kelvin and degrees Fahrenheit involve both multiplication and addition. Because such conversions violate the assumption stated above, they are unsupported at present.

    Conversions to constrained values are also presently unsupported. For example, it may be necessary, in certain applications, to require that a PlaneAngle measured in radians lie in the range (-pi, +pi], while other applications may require the range [0, 2 pi) instead. This and similar conversion-related issues ought be further considered.

  • Numerical accuracy and representations

    At present, the Library takes no special precautions to maximize numerical accuracy during its calculations. While we have encountered no specific problems caused by, say, rounding errors or the like, it can clearly become a source of concern. Since a user can tailor the underlying base representation via the world view, this problem may not be solvable in the most general case. However, some thought should be given to determine the most appropriate numerical methods.

    In addition, it has been suggested that, in some contexts, the underlying representation (e.g., double) might need to vary from dimension to dimension. For example, the BaBar experiment has mandated (Porter and Jacobsen, p. 1) that "[t]imes shall be stored as fixed point numbers ...." and goes on to discuss, in a very brief footnote, the merits of "a 31 [sic] bit signed integer" representation. It is unclear whether the current implementation of the Library can be adapted to permit such integral Times while maintaining, say, Lengths as doubles.

    Finally, a correspondent (Ottinger) has expressed a desire to track a value's "quality" as it evolves numerically. While not specified in complete detail, this appears to be somewhat similar to the concept of attaching an error estimate to each calculated value. This request appears to be a problem arising independently of this Library. If solved in a general (perhaps templatized) way, the solution can likely be applied to the objects created and supported by the Library. An assessment of this ought be performed.

  • Databases

    Certainly, adding more units and other useful constants to the Library's will be an on-going process for some time. It is, in fact, probable that significant such additions will have taken place since this paper was written.

    There is some interest in augmenting the Library by establishing one or more databases of useful physical constants. Constants of interest to be pursued heavily depend, of course, on the applications to be made of the Library. Possibilities already suggested include selected properties of the chemical elements, properties of various atomic particles, and the like.


    Concluding Remarks

    This paper has presented the concept of type-checking as the computer analog of manual calculation with units. The benefits of type-checking have been set forth, together with empirical evidence that programmers do not today apply type-checking to its fullest potential in numeric computation.

    The thrust of the paper has been the general description of the project known as The SI Library of Unit-based Computation, a software subsystem intended to apply the documented benefits of type-checking to numeric computation with no run-time overhead in either time or space. Convenience of use, economy of application, and ease of extensibility were primary objectives of the project.

    All major features of the SI Library have been discussed, and examples of its utility have been presented. User extensions have been described, as have certain options for future enhancement of the project.

    We conclude that the SI Library software project has met each of its objectives, and has exceeded many of them. To quote sample user reaction to date, "[the SI Library] is the first really good reason I've seen to switch from Fortran to C++." (Thank you!)


    Acknowledgements

    I extend grateful thanks to the following individuals for their contributions as noted below. Their efforts helped significantly in advancing this project, and are greatly appreciated.

    In addition to his general support as chair of the Fermi Physics Class Library Task Force, Mark Fischler first suggested applying the core of the SI Library to additional models, leading to the world view concept. He also defined the desired properties of the advanced physics models and assisted materially in validating the Library's behavior in these models. Isi Dunietz also assisted with some of this validation and with proofing.

    Valerie, Leo, and Richard Brown helped to proofread the Library's units and other constants. In addition, Valerie Brown proofread numerous drafts of this paper; her comments were instrumental in materially improving the exposition.

    Finally, Carol Brown made it possible for me to spend significant time to work on this project at home. Her support and her love are appreciated above all.


    Bibliography

    Aus der Au, Willy R.:
    "Converter Pro (16-bit) for Windows 3.1 and Converter Pro (32-bit) for Windows 95/98/NT." Internet: http://www.accsoft-ch.com/co102.htm, AccSoft Shareware: Staefa, Switzerland.
    Caso, Carlo, et al.:
    "Review of Particle Physics." The European Physical Journal, C3 (1998) pp. 69-70, 73.
    Fagan, Mike:
    Soft Typing: An Approach to Type Checking for Dynamically Typed Languages. Technical Report 92-184, Rice University, March 31, 1992.
    Fischler, Mark S.:
    units.note. Unpublished, updated August 14, 1998.
    Gannon, John D.:
    "An Experimental Evaluation of Data Type Conventions." Communications of the ACM, 20:8 (August, 1977), pp. 584-595.
    Halliday, David and Robert Resnick:
    Fundamentals of Physics. John Wiley & Sons, Inc., 1970. SBN 471 34430 3.
    Horvath, Ari L.:
    Conversion Tables of Units in Science & Engineering. The Macmillan Press Ltd., 1986. ISBN 0-444-01150-1.
    International Standards Organization, JTC1/SC22:
    Programming Languages -- C++. ISO/IEC FDIS 14882, 1998.
    Lasiuk, Brian and Thomas Ullrich:
    Comments on the Use of CLHEP for STAR. Internet: http://star.physics.yale.edu/preprint/papers/clhep.ps, STAR note 329, YRHI-98-08.
    Maire, Michel and Evgueni Tcherniaev:
    Units/PhysicalConstants.h. In CLHEP v1.3, CERN, 1998.
    Maire, Michel and Evgueni Tcherniaev:
    Units/SystemOfUnits.h. In CLHEP v1.3, CERN, 1998.
    Montanet, L., et al.:
    "Review of Particle Properties." Physical Review, D50 (1994), pp. 1233-4.
    Oliver, Robert:
    "Re: Metric and English Units conversion/formatting?" Newsgroup comp.lang.c++.moderated, June 18, 1998.
    Ottinger, Tim:
    Private communication. June 17, 1998.
    Pennycuick, Colin J.:
    Conversion Factors: S. I. Units and Many Others. Univ. of Chicago Press, 1988. ISBN 0-226-65507-5.
    Porter, Frank and Bob Jacobsen:
    Preferred Units for BaBar Software. Internet: http://hepunx.rl.ac.uk/BFROOT/doc/Computing/Standards/Units.ps, Oct. 14, 1995.
    Stroustrup, Bjarne:
    The Design and Evolution of C++. Addison-Wesley Publishing Co., 1994. ISBN 0-201-54330-3.
    Wolfram, Stephen:
    Mathematica: A System for Doing Mathematics by Computer. Addison-Wesley Publishing Co., Inc., 1988. ISBN 0-201-19334-5.


    Tables of Predeclared Types

    In the following tables, the name of each data type is followed by seven numbers, one for each base dimension, that together specify the dimensionality of the data type. Remarks are used to suggest the dimensions' definitions or to provide typical units of measurements. Units preceded by an asterisk are fundamental to SI.

  • Single dimensions

    Base dimensions m kg s A K mol cd Remarks
    Dimensionless 0 0 0 0 0 0 0 * -
    Length 1 0 0 0 0 0 0 * m
    Mass 0 1 0 0 0 0 0 * kg
    Time 0 0 1 0 0 0 0 * s
    Current 0 0 0 1 0 0 0 * A
    Temperature 0 0 0 0 1 0 0 * K
    AmountOfSubstance 0 0 0 0 0 1 0 * mol
    LuminousIntensity 0 0 0 0 0 0 1 * cd

    Dimensionless m kg s A K mol cd Remarks
    MassFraction 0 0 0 0 0 0 0 Mass per Mass
    Number 0 0 0 0 0 0 0 * -
    PlaneAngle 0 0 0 0 0 0 0 * rad = m per m
    SolidAngle 0 0 0 0 0 0 0 * sr = m per m
    SpecificGravity 0 0 0 0 0 0 0 Density per Density

    Length m kg s A K mol cd Remarks
    Altitude 1 0 0 0 0 0 0 Length
    Breadth 1 0 0 0 0 0 0
    Circumference 1 0 0 0 0 0 0
    Depth 1 0 0 0 0 0 0
    Diameter 1 0 0 0 0 0 0
    Distance 1 0 0 0 0 0 0
    Height 1 0 0 0 0 0 0
    PathLength 1 0 0 0 0 0 0
    Perimeter 1 0 0 0 0 0 0
    RadialDistance 1 0 0 0 0 0 0
    Radius 1 0 0 0 0 0 0
    Thickness 1 0 0 0 0 0 0
    WaveLength 1 0 0 0 0 0 0
    Width 1 0 0 0 0 0 0
    Area 2 0 0 0 0 0 0 Length^2
    FuelConsumption 2 0 0 0 0 0 0 Volume per Distance
    Capacity 3 0 0 0 0 0 0 Volume
    Volume 3 0 0 0 0 0 0 Length^3
    WaveNumber -1 0 0 0 0 0 0 reciprocal Length
    Mileage -2 0 0 0 0 0 0 Distance per Volume

    Mass m kg s A K mol cd Remarks
    AtomicMass 0 1 0 0 0 0 0 AtomicWeight · mole

    Time m kg s A K mol cd Remarks
    TimeSquared 0 0 2 0 0 0 0 s2
    AngularVelocity 0 0 -1 0 0 0 0 rad per s
    Frequency 0 0 -1 0 0 0 0 * Hz = reciprocal s
    RadionuclideActivity 0 0 -1 0 0 0 0 * Bq = reciprocal s
    Radioactivity 0 0 -1 0 0 0 0
    RotationalFrequency 0 0 -1 0 0 0 0 reciprocal s
    RotationalSpeed 0 0 -1 0 0 0 0 reciprocal Time
    RotationalVelocity 0 0 -1 0 0 0 0
    VelocityGradient 0 0 -1 0 0 0 0
    AngularAcceleration 0 0 -2 0 0 0 0 rad per s2

    Current m kg s A K mol cd Remarks
    Amperage 0 0 0 1 0 0 0 * A
    ElectricCurrent 0 0 0 1 0 0 0
    MagnetomotiveForce 0 0 0 1 0 0 0

    AmountOfSubstance m kg s A K mol cd Remarks
    Molarity 0 0 0 0 0 1 0 AmountOfSubstance
    MolarQuantity 0 0 0 0 0 1 0
    InverseMolarity 0 0 0 0 0 -1 0 reciprocal mol

    LuminousIntensity m kg s A K mol cd Remarks
    Luminosity 0 0 0 0 0 0 1 LuminousIntensity
    LuminousFlux 0 0 0 0 0 0 1 * lm = cd

  • Pairs of dimensions

    Length-Mass m kg s A K mol cd Remarks
    MomentOfInertia 2 1 0 0 0 0 0 Mass · Area
    SpecificSurface 2 -1 0 0 0 0 0 Area per Mass
    SpecificVolume 3 -1 0 0 0 0 0 reciprocal Density
    LineDensity -1 1 0 0 0 0 0 Mass per Length
    LinearDensity -1 1 0 0 0 0 0
    AreaDensity -2 1 0 0 0 0 0 Mass per Area
    AreaPressure -2 1 0 0 0 0 0
    BioMassDensity -2 1 0 0 0 0 0
    Density -3 1 0 0 0 0 0 Mass per Volume
    MassDensity -3 1 0 0 0 0 0
    VolumetricDensity -3 1 0 0 0 0 0

    Length-Time m kg s A K mol cd Remarks
    LinearVelocity 1 0 -1 0 0 0 0 Length per Time
    Speed 1 0 -1 0 0 0 0
    Velocity 1 0 -1 0 0 0 0
    Acceleration 1 0 -2 0 0 0 0 Length per Time^2
    GravitationalField 1 0 -2 0 0 0 0
    DiffusionCoefficient 2 0 -1 0 0 0 0 Area per Time
    KinematicViscosity 2 0 -1 0 0 0 0
    ThermalDiffusivity 2 0 -1 0 0 0 0
    AbsorbedDose 2 0 -2 0 0 0 0 * Gy = m2 per s2
    DoseEquivalent 2 0 -2 0 0 0 0 * Sv = m2 per s2
    Enthalpy 2 0 -2 0 0 0 0 J per kg
    GravitationalPotential 2 0 -2 0 0 0 0 Length^2 per Time^2
    Kerma 2 0 -2 0 0 0 0 * Gy
    RadiationDoseAbsorbed 2 0 -2 0 0 0 0
    RadiationDoseEquivalent 2 0 -2 0 0 0 0 * Sv = m2 per s2
    SpecificEnergy 2 0 -2 0 0 0 0 Energy per Mass
    AbsorbedDoseRate 2 0 -3 0 0 0 0 Gy per s
    MetabolicRate 2 0 -3 0 0 0 0 W per kg
    SpecificPowerOutput 2 0 -3 0 0 0 0 W per kg
    VolumeRateOfFlow 3 0 -1 0 0 0 0 Volume per Time

    Length-Current m kg s A K mol cd Remarks
    MagneticDipoleMoment 2 0 0 1 0 0 0 Current · Area
    MagneticQuadrupoleMoment 3 0 0 1 0 0 0 Current · Volume
    LinearCurrentDensity -1 0 0 1 0 0 0
    MagneticFieldStrength -1 0 0 1 0 0 0 Current per Distance
    Magnetization -1 0 0 1 0 0 0
    MagnetizingField -1 0 0 1 0 0 0
    CurrentDensity -2 0 0 1 0 0 0 Current per Area

    Length-AmountOfSubstance m kg s A K mol cd Remarks
    MolarVolume 3 0 0 0 0 -1 0 Volume per Molarity
    Concentration -3 0 0 0 0 1 0 Molarity per Volume

    Length-LuminousIntensity m kg s A K mol cd Remarks
    Brightness -2 0 0 0 0 0 1
    Illuminance -2 0 0 0 0 0 1 * lx = cd per m2
    Illumination -2 0 0 0 0 0 1
    Luminance -2 0 0 0 0 0 1

    Mass-Time m kg s A K mol cd Remarks
    MassRateOfFlow 0 1 -1 0 0 0 0 Mass per Time
    SurfaceTension 0 1 -2 0 0 0 0 Force per Length
    EnergyFlux 0 1 -3 0 0 0 0 kg per s3
    HeatFluxDensity 0 1 -3 0 0 0 0 Heat per Area · Time
    Irradiance 0 1 -3 0 0 0 0 W per m2
    Productivity 0 1 -3 0 0 0 0 kg per s3
    Radiance 0 1 -3 0 0 0 0 W per m2 · sr

    Mass-AmountOfSubstance m kg s A K mol cd Remarks
    AtomicWeight 0 1 0 0 0 -1 0 kg per mol

    Time-Current m kg s A K mol cd Remarks
    Charge 0 0 1 1 0 0 0 * C = A · s
    ElectricCharge 0 0 1 1 0 0 0 Current · Time

  • Dimension triples

    Length-Mass-Time m kg s A K mol cd Remarks
    LinearMomentum 1 1 -1 0 0 0 0 Mass · Velocity
    Momentum 1 1 -1 0 0 0 0 LinearMomentum
    TranslationalMomentum 1 1 -1 0 0 0 0
    Force 1 1 -2 0 0 0 0 * N = kg · m per s2
    Weight 1 1 -2 0 0 0 0 Mass · Acceleration
    PermeabilityCoefficient 1 1 -3 0 0 0 0
    Action 2 1 -1 0 0 0 0 J s
    AngularMomentum 2 1 -1 0 0 0 0 Length · LinearMomentum
    ElectricalEnergy 2 1 -2 0 0 0 0
    Energy 2 1 -2 0 0 0 0 * J = N · m
    Heat 2 1 -2 0 0 0 0
    HeatEnergy 2 1 -2 0 0 0 0
    KineticEnergy 2 1 -2 0 0 0 0
    MechanicalEnergy 2 1 -2 0 0 0 0
    MomentOfForce 2 1 -2 0 0 0 0 Torque
    PotentialEnergy 2 1 -2 0 0 0 0
    RadiantEnergy 2 1 -2 0 0 0 0
    Torque 2 1 -2 0 0 0 0
    Work 2 1 -2 0 0 0 0 Force · Distance
    EnergyConsumption 2 1 -3 0 0 0 0 Energy per Time
    Power 2 1 -3 0 0 0 0 * W = J per s
    HeatFlowRate 2 1 -3 0 0 0 0
    RadiantFlux 2 1 -3 0 0 0 0 J per s
    RadiantIntensity 2 1 -3 0 0 0 0 W per sr
    EnergyLength 3 1 -2 0 0 0 0 J · m
    GravitationalConstant 3 -1 -2 0 0 0 0 m3 per s2 · kg
    EnergyArea 4 1 -2 0 0 0 0 J · m2
    AbsoluteViscosity -1 1 -1 0 0 0 0 Pa · s
    DynamicViscosity -1 1 -1 0 0 0 0 Stress per VelocityGradient
    Viscosity -1 1 -1 0 0 0 0
    EnergyDensity -1 1 -2 0 0 0 0 Energy per Volume
    HeatDensity -1 1 -2 0 0 0 0
    Pressure -1 1 -2 0 0 0 0 Force per Area
    Stress -1 1 -2 0 0 0 0 * Pa = kg per m · s3
    HeatReleaseRate -1 1 -3 0 0 0 0 Heat per Volume · Time

    Length-Time-Current m kg s A K mol cd Remarks
    ElectricDipoleMoment 1 0 1 1 0 0 0 C · m
    ElectricQuadrupoleMoment 2 0 1 1 0 0 0 m2 · s · A
    DielectricDisplacement -2 0 1 1 0 0 0 C per m2
    ElectricDisplacement -2 0 1 1 0 0 0
    ElectricFluxDensity -2 0 1 1 0 0 0 Charge per Area
    ElectricPolarization -2 0 1 1 0 0 0
    Polarization -2 0 1 1 0 0 0
    ElectricChargeDensity -3 0 1 1 0 0 0 C per m3
    VolumeDensityOfCharge -3 0 1 1 0 0 0 Charge per Volume

    Length-Time-Temperature m kg s A K mol cd Remarks
    SpecificEntropy 2 0 -2 0 -1 0 0 J per kg · K

    Mass-Time-Current m kg s A K mol cd Remarks
    SpecificHeatCapacity 2 0 -2 0 -1 0 0 Heat per Mass · Temperature
    MagneticField 0 1 -2 -1 0 0 0 * T = V · s · m2
    MagneticFluxDensity 0 1 -2 -1 0 0 0
    MagneticInduction 0 1 -2 -1 0 0 0
    Exposure 0 -1 1 1 0 0 0 C per kg
    Radiation 0 -1 1 1 0 0 0
    SpecificCharge 0 -1 1 1 0 0 0 Charge per Mass

    Mass-Time-Temperature m kg s A K mol cd Remarks
    ThermalConductance 0 1 -3 0 -1 0 0 Heat per Area · Time · Temperature

  • Dimension 4-tuples

    Length-Mass-Time-Current m kg s A K mol cd Remarks
    MagneticPermeability 1 1 -2 -2 0 0 0 H per m
    Permeability 1 1 -2 -2 0 0 0
    ElectricFieldIntensity 1 1 -3 -1 0 0 0
    ElectricFieldStrength 1 1 -3 -1 0 0 0 V per m
    MagneticFlux 2 1 -2 -1 0 0 0 * Wb = V · s
    Inductance 2 1 -2 -2 0 0 0 * H
    Permeance 2 1 -2 -2 0 0 0 MagneticFlux per Current
    ElectricPotential 2 1 -3 -1 0 0 0 * V
    EM_Force 2 1 -3 -1 0 0 0
    Potential 2 1 -3 -1 0 0 0 J per C
    Voltage 2 1 -3 -1 0 0 0 Energy per Charge
    ElectricResistance 2 1 -3 -2 0 0 0 * Ohm
    Resistance 2 1 -3 -2 0 0 0 Potential per Current
    ElectricResistivity 3 1 -3 -2 0 0 0 Ohm · m
    SpecificResistance 3 1 -3 -2 0 0 0
    Reluctance -2 -1 2 2 0 0 0 MagneticPotential per MagnetixFlux
    Conductance -2 -1 3 2 0 0 0 * S = reciprocal Ohm
    ElectricConductance -2 -1 3 2 0 0 0 reciprocal Resistance
    Capacitance -2 -1 4 2 0 0 0 Charge per Voltage
    ElectricCapacitance -2 -1 4 2 0 0 0 * F
    ElectricConductivity -3 -1 3 2 0 0 0 reciprocal ElectricResistivity
    ElectricPermittivity -3 -1 4 2 0 0 0 F per m
    Permittivity -3 -1 4 2 0 0 0

    Length-Mass-Time-Temperature m kg s A K mol cd Remarks
    ThermalConductivity 1 1 -3 0 -1 0 0 Heat per Length · Time · Temperature
    Entropy 2 1 -2 0 -1 0 0 J per K
    HeatCapacity 2 1 -2 0 -1 0 0
    VolumetricHeatCapacity -1 1 -2 0 -1 0 0 Heat per Volume · Temperature
    ThermalResistivity -1 -1 3 0 1 0 0 Length · Time · Temperature per Heat

    Length-Mass-Time-AmountOfSubstance m kg s A K mol cd Remarks
    MolarEnergy 2 1 -2 0 0 -1 0 J per mol
    MolecularEnergy 2 1 -2 0 0 -1 0 Energy per MolarQuantity

    Length-Mass-Time-LuminousIntensity m kg s A K mol cd Remarks
    LuminousEfficacy 2 1 -3 0 0 0 -1 W · sr per cd

  • Dimension 5-tuples

    Length-Mass-Time-Temp.-AmtOfSubst. m kg s A K mol cd Remarks
    MolarEntropy 2 1 -2 0 -1 -1 0 J per mol · K
    MolarHeatCapacity 2 1 -2 0 -1 -1 0 Heat per MolarQuantity · Temperature
    GasConstant 2 1 -1 0 -1 -1 0 Heat per MolarQuantity · Temperature


    Tables of Predefined Units, Prefixes, and Constants

  • Standard SI prefixes (dimensionless)

    Prefixes to form multiples of SI units:

    Data Type Name Abbr. Value
    Number deka_ da_ 1e+01
    Number hecto_ h_ 1e+02
    Number kilo_ k_ 1e+03
    Number mega_ M_ 1e+06
    Number giga_ G_ 1e+09
    Number tera_ T_ 1e+12
    Number peta_ P_ 1e+15
    Number exa_ E_ 1e+18
    Number zetta_ Z_ 1e+21
    Number yotta_ Y_ 1e+24

    Prefixes to form submultiples of SI units:

    Data Type Name Abbr. Value
    Number deci_ d_ 1e-01
    Number centi_ c_ 1e-02
    Number milli_ m_ 1e-03
    Number micro_ u_ 1e-06
    Number nano_ n_ 1e-09
    Number pico_ p_ 1e-12
    Number femto_ f_ 1e-15
    Number atto_ a_ 1e-18
    Number zepto_ z_ 1e-21
    Number yocto_ y_ 1e-24

  • Base (default) SI units

    The values shown for these units are those in the standard world view. Other world views can recalibrate these values, if desired.


    Data Type Name Abbr. Value
    Length meter m 1
    Mass kilogram kg 1
    Time second s 1
    Current ampere A, amp 1
    Temperature kelvin K 1
    AmountOfSubstance mole mol 1
    LuminousIntensity candela cd 1

  • Derived and supplementary SI units having special symbols

    Data Type Name Abbr. Value
    Radioactivity becquerel Bq reciprocal s
    ElectricCharge coulomb C s · A
    Capacitance farad F sq(C) · sq(s) per (kg · sq(m))
    SpecificEnergy gray Gy sq(m) per sq(s)
    Inductance henry H sq(m) · kg per sq(C)
    Frequency hertz Hz reciprocal s
    Energy joule J sq(m) · kg per sq(s)
    LuminousFlux lumen lm cd · sq(m) per sq(m)
    Illuminance lux lx lm per sq(m)
    Force newton N m · kg per sq(s)
    ElectricResistance ohm
    J per (C · A)
    Pressure pascal Pa N per sq(m)
    PlaneAngle radian rad m per m
    ElectricConductance siemens S reciprocal ohm
    DoseEquivalent sievert Sv J per kg
    SolidAngle steradian sr sq(m) per sq(m)
    MagneticFluxDensity tesla T kg per (s · C)
    ElectricPotential volt V J per C
    Power watt W J per s
    MagneticFlux weber Wb V · s

  • Dimensionless constants and units

    Fractions:

    Data Type Name Abbr. Value
    Number perCent
    0.01
    Number perThousand
    0.001
    Number perMillion
    0.000001
    Number semi_
    0.5
    Number hemi_
    0.5
    Number demi_
    0.5

    Numerical constants:

    Data Type Name Abbr. Value
    Number pi
    3.14159265358979323846
    Number twopi
    2.0 · pi
    Number halfpi
    0.5 · pi
    Number pi2
    sq(pi)
    Number e
    2.7182818284590452354
    Number gamma
    0.577215664901532861

    Angle units:

    Data Type Name Abbr. Value
    PlaneAngle milliradian mrad milli_ · rad
    PlaneAngle degree deg pi / 180 · rad
    PlaneAngle rightangle
    halfpi · rad
    PlaneAngle revolution
    twopi · rad
    PlaneAngle turn
    revolution
    PlaneAngle circle
    revolution
    SolidAngle sphere
    4. · pi · sr
    SolidAngle space
    4. · pi · sr
    SolidAngle hemisphere
    hemi_ · sphere

  • Single-dimension constants and units

    Linear measure (metric):

    Data Type Name Abbr. Value
    Length kilometer km kilo_ · m
    Length nauticalmile NM 1852. · m
    Length centimeter cm centi_ · m
    Length millimeter mm milli_ · m
    Length micrometer
    micro_ · m
    Length micron
    micro_ · m
    Length nanometer nm nano_ · m
    Length bicron
    pico_ · m
    Length fermi
    femto_ · m
    Length angstrom
    1e-10 · m
    Length rowland
    angstrom

    Linear measure (English):

    Data Type Name Abbr. Value
    Length inch in 2.54 · cm
    Length mil
    0.001 · in
    Length foot ft 12. · in
    Length yard yd 3. · ft
    Length fathom
    6. · ft
    Length rod
    16.5 · ft
    Length pole
    rod
    Length perch
    rod
    Length furlong
    660. · ft
    Length mile mi 5280. · ft

    Quadratic measure (metric):

    Data Type Name Abbr. Value
    Area squareMeter m2 sq( m)
    Area squareMillimeter mm2 sq(mm)
    Area squareCentimeter cm2 sq(cm)
    Area squareKilometer km2 sq(km)
    Area barn
    1e-28 · m2
    Area millibarn mbarn milli_ · barn
    Area microbarn
    micro_ · barn
    Area nanobarn
    nano_ · barn
    Area shed
    1e-52 · m2

    Quadratic measure (English):

    Data Type Name Abbr. Value
    Area are a 100 · m2
    Area hectare ha hecto_ · a
    Area acre
    160 · sq(rod)

    Cubic measure (metric):

    Data Type Name Abbr. Value
    Volume cubicMeter m3 cub( m)
    Volume stere
    m3
    Volume cubicMillimeter mm3 cub(mm)
    Volume cubicCentimeter cm3 cub(cm)
    Volume cc
    cm3
    Volume cubicKilometer km3 cub(km)
    Volume liter l 1e-3 · m3
    Volume milliliter ml milli_ · l

    Cubic measure (English):

    Data Type Name Abbr. Value
    Volume cordfoot
    16. · cub(ft)
    Volume cord
    8. · cordfoot

    Mass measure (metric):

    Data Type Name Abbr. Value
    Mass gram g milli_ · kg
    Mass centigram cg centi_ · g
    Mass milligram mg milli_ · g
    Mass tonneau
    mega_ · g
    Mass tonne
    tonneau

    Mass measure (English):

    Data Type Name Abbr. Value
    Mass pound lb 0.45359237 · kg
    Mass ounce oz lb / 16.

    Time measure:

    Data Type Name Abbr. Value
    Time millisecond ms milli_ · s
    Time microsecond us micro_ · s
    Time nanosecond ns nano_ · s
    Time shake
    1e-8 · s
    Time minute min 60 · s
    Time hour hr 60 · min
    Time aeon
    3.1536e16 · s
    Time blink
    0.864 · s
    Time cron
    3.156e13 · s
    Frequency kilohertz kHz kilo_ · Hz
    Frequency megahertz MHz mega_ · Hz
    Radioactivity curie Ci 3.7e+10 · Bq
    Radioactivity millicurie mCi milli_ · Ci
    Radioactivity microcurie uCi micro_ · Ci

  • Dimension-pair constants and units

    Length-Mass measure:

    Data Type Name Abbr. Value
    LineDensity tex
    mg / m
    LineDensity drex
    deci_ · tex
    LineDensity denier
    tex / 9.

    Length-Time measure:

    Data Type Name Abbr. Value
    Velocity benz
    m / s
    Velocity kine
    cm / s
    Velocity knot
    nauticalmile / hr
    Velocity Mach
    331.5 · m / s
    Acceleration Galileo Gal cm / sq(s)
    Acceleration leo
    10. · m / sq(s)
    SpecificEnergy radiationdose rad centi_ · Gy
    DoseEquivalent Rem
    centi_ · Sv
    DoseEquivalent millirem mRem milli_ · Rem
    DoseEquivalent microrem uRem micro_ · Rem
    KinematicViscosity stokes
    1e-4 · sq(m) / s

    Time-Current measure:

    Data Type Name Abbr. Value
    ElectricCharge esu
    C / 2.99792458e9
    ElectricCharge abcoulomb
    10 · C
    ElectricCharge statcoulomb
    3.335635e-10 · C
    ElectricCharge franklin Fr 3.335635e-10 · C

    Length-LuminousIntensity measure:

    Data Type Name Abbr. Value
    Illuminance phot ph 1e4 · lx
    Illuminance stilb sb 1e4 · cd / m2
    Illuminance lambert
    lm / cm2

  • Dimension-triple constants and units

    Length-Mass-Time measure:

    Data Type Name Abbr. Value
    Force kilonewton kN kilo_ · N
    Force sthene
    kN
    Force meganewton MN mega_ · N
    Force dyne dyn 1e-5 · N
    Energy kilojoule kJ kilo_ · J
    Energy megajoule MJ mega_ · J
    Energy gigajoule GJ giga_ · J
    Energy erg
    1e-7 · J
    Energy electronvolt eV 1.60217733e-19 · J
    Energy kiloelectronvolt keV kilo_ · eV
    Energy megaelectronvolt MeV mega_ · eV
    Energy gigaelectronvolt GeV giga_ · eV
    Energy teraelectronvolt TeV tera_ · eV
    Heat therm
    1.055e8 · J
    Power kilowatt kW kilo_ · W
    Power megawatt MW mega_ · W
    Pressure bar
    1e+5 · Pa
    Pressure millibar mbar milli_ · bar
    Pressure atmosphere atm 101325. · Pa
    Pressure torr tor atm / 760.
    DynamicViscosity poise P g / ( cm · s )

    Mass-Time-Current measure:

    Data Type Name Abbr. Value
    MagneticFluxDensity gauss Gs 1e-4 · T
    MagneticFluxDensity kilogauss kGs kilo_ · Gs
    Exposure roentgen R 2.58e-4 · C / kg

  • Dimension-4tuple constants and units

    Length-Mass-Time-Current measure:

    Data Type Name Abbr. Value
    MagneticFlux maxwell
    1e-8 · Wb
    ElectricPotential kilovolt kV kilo_ · V
    ElectricPotential megavolt MV mega_ · V
    Capacitance millifarad mF milli_ · F
    Capacitance microfarad uF micro_ · F
    Capacitance nanofarad nF nano_ · F
    Capacitance picofarad pF pico_ · F

  • Dimension-5tuple constants and units

    Length-Mass-Time-Temp.-AmtOfSubst. measure:

    Data Type Name Abbr. Value
    MolarHeatCapacity Clausius
    J / (mol · K)

  • HEP-specific constants and units

    Data Type Name Abbr. Value
    Velocity lightspeed c * 299792458 · m / s
    SpecificEnergy lightspeed_squared c2 sq(c)
    Action Planck_constant h * 6.6260755e-34 · J · s
    Action reducedPlanck hBar h / twopi
    ElectricCharge positron_charge ePlus 1.60217733e-19 · C
    Mass electron_mass m_e 0.51099906 · MeV / c2
    Mass proton_mass m_p 938.27231 · MeV / c2
    Mass deuteron_mass m_d 1875.61339 · MeV / c2
    Mass neutron_mass m_n 939.56563 · MeV / c2
    Mass atomic_mass_unit amu 931.49432 · MeV / c2
    Permeability free_space_permeability mu_0 4e-7·pi · N / (A·A)
    Permittivity free_space_permittivity epsilon_0 reciprocal (mu_0 · c2)
    EnergyLength electromagnetic_coupling elmCoupling sq(ePlus) / (4·pi · epsilon_0 )
    Number fine_structure_constant alpha elmCoupling / (hBar · c )
    Length classical_electron_radius r_e elmCoupling / (m_e · c2 )
    Length electron_Compton_wavelength lambdaBar_e r_e / alpha
    Length Bohr_radius a_inf lambdaBar_e / alpha
    Energy Rydberg_energy hcR_inf m_e · c2 · sq(alpha) / 2
    Area Thomson_cross_section sigma_T 8·pi · sq(r_e) / 3
    MagneticDipoleMoment Bohr_magneton mu_B ePlus · hBar / (2 · m_e)
    MagneticDipoleMoment nuclear_magneton mu_N ePlus · hBar / (2 · m_p)
    GravitationalConstant Newtonian_gravitational_constant G_N * 6.67259e-11 · m3 / (kg · s·s)
    Acceleration gravitational_acceleration gSeaLevel 9.80665 · m / (s·s)
    InverseMolarity Avogadro_constant N_A 6.0221367e+23 / mol
    Entropy Boltzmann_constant k 1.380658e-23 · J / K
    Temperature STPtemp
    273.15 · K
    Pressure STPpressure
    atm
    MolarVolume IdealGasVolume
    N_A · k · STPtemp / STPpressure
    Length astronomical_unit AU 1.4959787066e11 · m
    Length parsec pc 3.0856775807e16 · m
    Density kGasThreshold
    cg / cm3
    Area electron_cross_section alpha_rcl2 alpha · sq(r_e)
    EnergyArea twopi_mc2_rcl2
    twopi · r_e · r_e · m_e · c2
    LuminousEfficacy luminousEfficacy540
    683. · W / (sr · cd)


    Table of Predefined World Views

    Model and Header Defining Characteristics Default Units
    standard
    #include "SIunits/stdModel"
    per Système Internationale m (Length), kg (Mass), s (Time), A (Current), K (Temperature), mol (Amount of Substance), cd (Luminous Intensity)
    relativistic
    #include "SIunits/relModel"
    c = 1 s (Length, Time), eV (Mass), A (Current), K (Temperature), mol (Amount of Substance), cd (Luminous Intensity)
    high-energy physics
    #include "SIunits/hepModel"
    c = Boltz const = ePlus = 1 ns (Length, Time), GeV (Mass, Temperature), ePlus (Charge), mol (Amount of Substance), cd (Luminous Intensity)
    quantum
    #include "SIunits/qtmModel"
    c = Boltz const = hBar = 1 inverse GeV (Length, Time), GeV (Mass, Temperature, Current), mol (Amount of Substance), cd (Luminous Intensity)
    natural
    #include "SIunits/natModel"
    c = Boltz const = hBar = grav const = 1 numeric only (Length, Mass, Time, Current, Temperature), mol (Amount of Substance), cd (Luminous Intensity)